@icure/api 8.0.79 → 8.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/icc-api/model/Content.js +1 -1
  2. package/icc-api/model/Content.js.map +1 -1
  3. package/icc-api/model/HealthcareParty.js +1 -1
  4. package/icc-api/model/HealthcareParty.js.map +1 -1
  5. package/icc-api/model/Patient.js +1 -1
  6. package/icc-api/model/Patient.js.map +1 -1
  7. package/icc-x-api/crypto/ExtendedApisUtils.d.ts +47 -2
  8. package/icc-x-api/crypto/ExtendedApisUtils.js.map +1 -1
  9. package/icc-x-api/crypto/ExtendedApisUtilsImpl.d.ts +8 -1
  10. package/icc-x-api/crypto/ExtendedApisUtilsImpl.js +81 -2
  11. package/icc-x-api/crypto/ExtendedApisUtilsImpl.js.map +1 -1
  12. package/icc-x-api/crypto/SecretIdUseOption.d.ts +60 -0
  13. package/icc-x-api/crypto/SecretIdUseOption.js +60 -0
  14. package/icc-x-api/crypto/SecretIdUseOption.js.map +1 -0
  15. package/icc-x-api/icc-accesslog-x-api.d.ts +2 -1
  16. package/icc-x-api/icc-accesslog-x-api.js +2 -3
  17. package/icc-x-api/icc-accesslog-x-api.js.map +1 -1
  18. package/icc-x-api/icc-calendar-item-x-api.d.ts +26 -3
  19. package/icc-x-api/icc-calendar-item-x-api.js +51 -16
  20. package/icc-x-api/icc-calendar-item-x-api.js.map +1 -1
  21. package/icc-x-api/icc-classification-x-api.d.ts +2 -1
  22. package/icc-x-api/icc-classification-x-api.js +2 -3
  23. package/icc-x-api/icc-classification-x-api.js.map +1 -1
  24. package/icc-x-api/icc-contact-x-api.d.ts +3 -2
  25. package/icc-x-api/icc-contact-x-api.js +5 -8
  26. package/icc-x-api/icc-contact-x-api.js.map +1 -1
  27. package/icc-x-api/icc-crypto-x-api.d.ts +1 -7
  28. package/icc-x-api/icc-crypto-x-api.js +1 -8
  29. package/icc-x-api/icc-crypto-x-api.js.map +1 -1
  30. package/icc-x-api/icc-document-x-api.d.ts +2 -1
  31. package/icc-x-api/icc-document-x-api.js +3 -6
  32. package/icc-x-api/icc-document-x-api.js.map +1 -1
  33. package/icc-x-api/icc-form-x-api.d.ts +2 -1
  34. package/icc-x-api/icc-form-x-api.js +2 -3
  35. package/icc-x-api/icc-form-x-api.js.map +1 -1
  36. package/icc-x-api/icc-helement-x-api.d.ts +3 -2
  37. package/icc-x-api/icc-helement-x-api.js +5 -8
  38. package/icc-x-api/icc-helement-x-api.js.map +1 -1
  39. package/icc-x-api/icc-invoice-x-api.d.ts +2 -1
  40. package/icc-x-api/icc-invoice-x-api.js +2 -3
  41. package/icc-x-api/icc-invoice-x-api.js.map +1 -1
  42. package/icc-x-api/icc-message-x-api.d.ts +2 -1
  43. package/icc-x-api/icc-message-x-api.js +2 -3
  44. package/icc-x-api/icc-message-x-api.js.map +1 -1
  45. package/icc-x-api/icc-patient-x-api.js +4 -6
  46. package/icc-x-api/icc-patient-x-api.js.map +1 -1
  47. package/icc-x-api/icc-topic-x-api.d.ts +2 -1
  48. package/icc-x-api/icc-topic-x-api.js +3 -2
  49. package/icc-x-api/icc-topic-x-api.js.map +1 -1
  50. package/icc-x-api/index.js +1 -3
  51. package/icc-x-api/index.js.map +1 -1
  52. package/package.json +1 -1
  53. package/test/icc-x-api/confidential-entities-test.js +49 -6
  54. package/test/icc-x-api/confidential-entities-test.js.map +1 -1
  55. package/test/icc-x-api/crypto/cryptoTest.js +5 -3
  56. package/test/icc-x-api/crypto/cryptoTest.js.map +1 -1
  57. package/test/icc-x-api/crypto/full-crypto-test.js +0 -2
  58. package/test/icc-x-api/crypto/full-crypto-test.js.map +1 -1
  59. package/test/icc-x-api/crypto/shamir.js +3 -1
  60. package/test/icc-x-api/crypto/shamir.js.map +1 -1
  61. package/test/icc-x-api/icc-calendar-item-x-api.js +1 -1
  62. package/test/icc-x-api/icc-calendar-item-x-api.js.map +1 -1
  63. package/test/icc-x-api/icc-contact-x-api.js +4 -2
  64. package/test/icc-x-api/icc-contact-x-api.js.map +1 -1
  65. package/test/icc-x-api/icc-helement-x-api-test.js +3 -1
  66. package/test/icc-x-api/icc-helement-x-api-test.js.map +1 -1
  67. package/icc-x-api/crypto/ConfidentialEntities.d.ts +0 -64
  68. package/icc-x-api/crypto/ConfidentialEntities.js +0 -112
  69. package/icc-x-api/crypto/ConfidentialEntities.js.map +0 -1
  70. package/test/icc-x-api/diocancaro.d.ts +0 -1
  71. package/test/icc-x-api/diocancaro.js +0 -75
  72. package/test/icc-x-api/diocancaro.js.map +0 -1
@@ -21,7 +21,7 @@ const ModelHelper_1 = require("./ModelHelper");
21
21
  class Content {
22
22
  constructor(json) {
23
23
  let binaryData = {};
24
- if (!!json.binaryValue) {
24
+ if (!!(json === null || json === void 0 ? void 0 : json.binaryValue)) {
25
25
  if (typeof json.binaryValue === 'string') {
26
26
  binaryData.binaryValue = (0, ModelHelper_1.b64_2ab)(json.binaryValue);
27
27
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Content.js","sourceRoot":"","sources":["../../../icc-api/model/Content.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;GAUG;AACH,uCAAmC;AAEnC,uCAAmC;AAGnC;;GAEG;AACH,+CAAuC;AACvC,MAAa,OAAO;IAClB,YAAY,IAAgB;QAC1B,IAAI,UAAU,GAAkC,EAAE,CAAA;QAClD,IAAI,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE;YACtB,IAAI,OAAO,IAAI,CAAC,WAAW,KAAK,QAAQ,EAAE;gBACxC,UAAU,CAAC,WAAW,GAAG,IAAA,qBAAO,EAAC,IAAI,CAAC,WAAW,CAAC,CAAA;aACnD;iBAAM,IAAI,IAAI,CAAC,WAAW,YAAY,WAAW,IAAI,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE;gBAC1F,UAAU,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAA;aAC1C;iBAAM;gBACL,MAAM,IAAI,KAAK,CAAC,iCAAiC,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,CAAA;aAC5E;SACF;QACD,MAAM,CAAC,MAAM,CAAC,IAAe,EAAE,IAAI,EAAE,UAAU,CAAC,CAAA;QAEhD,IAAI,CAAC,CAAC,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,YAAY,CAAA,EAAE;YACxB,IAAI,CAAC,YAAY,GAAG,IAAI,iBAAO,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;SACnD;QAED,IAAI,CAAC,CAAC,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,aAAa,CAAA,EAAE;YACzB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,OAAmB,EAAE,EAAE,CAAC,IAAI,iBAAO,CAAC,OAAO,CAAC,CAAC,CAAA;SAC3F;IACH,CAAC;CAqBF;AA1CD,0BA0CC","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 { Measure } from './Measure'\nimport { Medication } from './Medication'\nimport { Service } from './Service'\nimport { TimeSeries } from './TimeSeries'\n\n/**\n * Information contained in the service. Content is localized, using ISO language code as key\n */\nimport { b64_2ab } from './ModelHelper'\nexport class Content {\n constructor(json: JSON | any) {\n let binaryData: { binaryValue?: ArrayBuffer } = {}\n if (!!json.binaryValue) {\n if (typeof json.binaryValue === 'string') {\n binaryData.binaryValue = b64_2ab(json.binaryValue)\n } else if (json.binaryValue instanceof ArrayBuffer || ArrayBuffer.isView(json.binaryValue)) {\n binaryData.binaryValue = json.binaryValue\n } else {\n throw new Error(`Invalid type for binaryValue: ${typeof json.binaryValue}`)\n }\n }\n Object.assign(this as Content, json, binaryData)\n\n if (!!json?.measureValue) {\n this.measureValue = new Measure(json.measureValue)\n }\n\n if (!!json?.compoundValue) {\n this.compoundValue = json.compoundValue.map((service: JSON | any) => new Service(service))\n }\n }\n\n stringValue?: string\n numberValue?: number\n booleanValue?: boolean\n instantValue?: number\n /**\n * Value as date. The format could have a all three (day, month and year) or values on any of these three, whatever is known.\n */\n fuzzyDateValue?: number\n binaryValue?: ArrayBuffer\n /**\n * Linked document.\n */\n documentId?: string\n measureValue?: Measure\n medicationValue?: Medication\n timeSeries?: TimeSeries\n compoundValue?: Array<Service>\n ratio?: Array<Measure>\n range?: Array<Measure>\n}\n"]}
1
+ {"version":3,"file":"Content.js","sourceRoot":"","sources":["../../../icc-api/model/Content.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;GAUG;AACH,uCAAmC;AAEnC,uCAAmC;AAGnC;;GAEG;AACH,+CAAuC;AACvC,MAAa,OAAO;IAClB,YAAY,IAAgB;QAC1B,IAAI,UAAU,GAAkC,EAAE,CAAA;QAClD,IAAI,CAAC,CAAC,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAA,EAAE;YACvB,IAAI,OAAO,IAAI,CAAC,WAAW,KAAK,QAAQ,EAAE;gBACxC,UAAU,CAAC,WAAW,GAAG,IAAA,qBAAO,EAAC,IAAI,CAAC,WAAW,CAAC,CAAA;aACnD;iBAAM,IAAI,IAAI,CAAC,WAAW,YAAY,WAAW,IAAI,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE;gBAC1F,UAAU,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAA;aAC1C;iBAAM;gBACL,MAAM,IAAI,KAAK,CAAC,iCAAiC,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,CAAA;aAC5E;SACF;QACD,MAAM,CAAC,MAAM,CAAC,IAAe,EAAE,IAAI,EAAE,UAAU,CAAC,CAAA;QAEhD,IAAI,CAAC,CAAC,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,YAAY,CAAA,EAAE;YACxB,IAAI,CAAC,YAAY,GAAG,IAAI,iBAAO,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;SACnD;QAED,IAAI,CAAC,CAAC,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,aAAa,CAAA,EAAE;YACzB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,OAAmB,EAAE,EAAE,CAAC,IAAI,iBAAO,CAAC,OAAO,CAAC,CAAC,CAAA;SAC3F;IACH,CAAC;CAqBF;AA1CD,0BA0CC","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 { Measure } from './Measure'\nimport { Medication } from './Medication'\nimport { Service } from './Service'\nimport { TimeSeries } from './TimeSeries'\n\n/**\n * Information contained in the service. Content is localized, using ISO language code as key\n */\nimport { b64_2ab } from './ModelHelper'\nexport class Content {\n constructor(json: JSON | any) {\n let binaryData: { binaryValue?: ArrayBuffer } = {}\n if (!!json?.binaryValue) {\n if (typeof json.binaryValue === 'string') {\n binaryData.binaryValue = b64_2ab(json.binaryValue)\n } else if (json.binaryValue instanceof ArrayBuffer || ArrayBuffer.isView(json.binaryValue)) {\n binaryData.binaryValue = json.binaryValue\n } else {\n throw new Error(`Invalid type for binaryValue: ${typeof json.binaryValue}`)\n }\n }\n Object.assign(this as Content, json, binaryData)\n\n if (!!json?.measureValue) {\n this.measureValue = new Measure(json.measureValue)\n }\n\n if (!!json?.compoundValue) {\n this.compoundValue = json.compoundValue.map((service: JSON | any) => new Service(service))\n }\n }\n\n stringValue?: string\n numberValue?: number\n booleanValue?: boolean\n instantValue?: number\n /**\n * Value as date. The format could have a all three (day, month and year) or values on any of these three, whatever is known.\n */\n fuzzyDateValue?: number\n binaryValue?: ArrayBuffer\n /**\n * Linked document.\n */\n documentId?: string\n measureValue?: Measure\n medicationValue?: Medication\n timeSeries?: TimeSeries\n compoundValue?: Array<Service>\n ratio?: Array<Measure>\n range?: Array<Measure>\n}\n"]}
@@ -8,7 +8,7 @@ const ModelHelper_1 = require("./ModelHelper");
8
8
  class HealthcareParty {
9
9
  constructor(json) {
10
10
  let pictureData = {};
11
- if (!!json.picture) {
11
+ if (!!(json === null || json === void 0 ? void 0 : json.picture)) {
12
12
  if (typeof json.picture === 'string') {
13
13
  pictureData.picture = (0, ModelHelper_1.b64_2ab)(json.picture);
14
14
  }
@@ -1 +1 @@
1
- {"version":3,"file":"HealthcareParty.js","sourceRoot":"","sources":["../../../icc-api/model/HealthcareParty.ts"],"names":[],"mappings":";;;AAoBA;;GAEG;AACH,+CAAuC;AAEvC,MAAa,eAAe;IAC1B,YAAY,IAAgB;QAC1B,IAAI,WAAW,GAA8B,EAAE,CAAA;QAC/C,IAAI,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE;YAClB,IAAI,OAAO,IAAI,CAAC,OAAO,KAAK,QAAQ,EAAE;gBACpC,WAAW,CAAC,OAAO,GAAG,IAAA,qBAAO,EAAC,IAAI,CAAC,OAAO,CAAC,CAAA;aAC5C;iBAAM,IAAI,IAAI,CAAC,OAAO,YAAY,WAAW,IAAI,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE;gBAClF,WAAW,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAA;aACnC;iBAAM;gBACL,MAAM,IAAI,KAAK,CAAC,6BAA6B,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC,CAAA;aACpE;SACF;QACD,MAAM,CAAC,MAAM,CAAC,IAAe,EAAE,IAAI,EAAE,WAAW,CAAC,CAAA;IACnD,CAAC;CAsLF;AAnMD,0CAmMC;AACD,WAAiB,eAAe;IAEjB,0BAAU,GAAG;QACxB,IAAI,EAAE,MAAoB;QAC1B,MAAM,EAAE,QAAsB;QAC9B,aAAa,EAAE,eAA6B;QAC5C,OAAO,EAAE,SAAuB;QAChC,aAAa,EAAE,eAA6B;QAC5C,eAAe,EAAE,iBAA+B;QAChD,OAAO,EAAE,SAAuB;KACjC,CAAA;IAEY,4BAAY,GAAG;QAC1B,OAAO,EAAE,SAAyB;QAClC,cAAc,EAAE,gBAAgC;QAChD,YAAY,EAAE,cAA8B;KAC7C,CAAA;AACH,CAAC,EAjBgB,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAiB/B","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 { Address } from './Address'\nimport { CodeStub } from './CodeStub'\nimport { FinancialInstitutionInformation } from './FinancialInstitutionInformation'\nimport { FlatRateTarification } from './FlatRateTarification'\nimport { HealthcarePartyHistoryStatus } from './HealthcarePartyHistoryStatus'\nimport { Identifier } from './Identifier'\nimport { PersonName } from './PersonName'\nimport { PropertyStub } from './PropertyStub'\n\n/**\n * This entity is a root level object. It represents a healthcare party. It is serialized in JSON and saved in the underlying icure-healthdata CouchDB database.\n */\nimport { b64_2ab } from './ModelHelper'\nimport { Patient } from './Patient'\nexport class HealthcareParty {\n constructor(json: JSON | any) {\n let pictureData: { picture?: ArrayBuffer } = {}\n if (!!json.picture) {\n if (typeof json.picture === 'string') {\n pictureData.picture = b64_2ab(json.picture)\n } else if (json.picture instanceof ArrayBuffer || ArrayBuffer.isView(json.picture)) {\n pictureData.picture = json.picture\n } else {\n throw new Error(`Invalid type for picture: ${typeof json.picture}`)\n }\n }\n Object.assign(this as Patient, json, pictureData)\n }\n\n /**\n * the Id of the healthcare party. We encourage using either a v4 UUID or a HL7 Id.\n */\n id?: string\n /**\n * the revision of the healthcare party in the database, used for conflict management / optimistic locking.\n */\n rev?: string\n /**\n * creation timestamp of the object.\n */\n created?: number\n /**\n * last modification timestamp of the object.\n */\n modified?: number\n /**\n * hard delete (unix epoch in ms) timestamp of the object. Filled automatically when deletePatient is called.\n */\n deletionDate?: number\n /**\n * The healthcareparty's identifiers, used by the client to identify uniquely and unambiguously the HCP. However, iCure may not guarantee this uniqueness by itself : This should be done at the client side.\n */\n identifier?: Array<Identifier>\n /**\n * A tag is an item from a codification system that qualifies an entity as being member of a certain class, whatever the value it might have taken. If the tag qualifies the content of a field, it means that whatever the content of the field, the tag will always apply. For example, the label of a field is qualified using a tag. LOINC is a codification system typically used for tags.\n */\n tags?: Array<CodeStub>\n /**\n * A code is an item from a codification system that qualifies the content of this entity. SNOMED-CT, ICPC-2 or ICD-10 codifications systems can be used for codes\n */\n codes?: Array<CodeStub>\n /**\n * The full name of the healthcare party, used mainly when the healthcare party is an organization\n */\n name?: string\n /**\n * the lastname (surname) of the healthcare party. This is the official lastname that should be used for official administrative purposes.\n */\n lastName?: string\n /**\n * the firstname (name) of the healthcare party.\n */\n firstName?: string\n /**\n * the list of all names of the healthcare party, also containing the official full name information. Ordered by preference of use. First element is therefore the official name used for the healthcare party in the application\n */\n names?: Array<PersonName>\n /**\n * the gender of the healthcare party: male, female, indeterminate, changed, changedToMale, changedToFemale, unknown\n */\n gender?: HealthcareParty.GenderEnum\n /**\n * Mr., Ms., Pr., Dr. ...\n */\n civility?: string\n /**\n * The name of the company this healthcare party is member of\n */\n companyName?: string\n /**\n * Medical specialty of the healthcare party\n */\n speciality?: string\n /**\n * Bank Account identifier of the healhtcare party, IBAN, deprecated, use financial institutions instead\n */\n bankAccount?: string\n /**\n * Bank Identifier Code, the SWIFT Address assigned to the bank, use financial institutions instead\n */\n bic?: string\n proxyBankAccount?: string\n proxyBic?: string\n /**\n * All details included in the invoice header\n */\n invoiceHeader?: string\n /**\n * Identifier number for institution type if the healthcare party is an enterprise\n */\n cbe?: string\n /**\n * Identifier number for the institution if the healthcare party is an organization\n */\n ehp?: string\n /**\n * The id of the user that usually handles this healthcare party.\n */\n userId?: string\n /**\n * Id of parent of the user representing the healthcare party.\n */\n parentId?: string\n convention?: number\n /**\n * National Institute for Health and Invalidity Insurance number assigned to healthcare parties (institution or person).\n */\n nihii?: string\n nihiiSpecCode?: string\n /**\n * Social security inscription number.\n */\n ssin?: string\n /**\n * The list of addresses (with address type).\n */\n addresses?: Array<Address>\n /**\n * The list of languages spoken by the patient ordered by fluency (alpha-2 code http://www.loc.gov/standards/iso639-2/ascii_8bits.html).\n */\n languages?: Array<string>\n /**\n * A picture usually saved in JPEG format.\n */\n picture?: ArrayBuffer\n /**\n * The healthcare party's status: 'trainee' or 'withconvention' or 'accredited'\n */\n statuses?: Array<HealthcareParty.StatusesEnum>\n /**\n * The healthcare party's status history\n */\n statusHistory?: Array<HealthcarePartyHistoryStatus>\n /**\n * Medical specialty of the healthcare party codified using FHIR or Kmehr codificaiton scheme\n */\n specialityCodes?: Array<CodeStub>\n /**\n * The type of format for contacting the healthcare party, ex: mobile, phone, email, etc.\n */\n sendFormats?: { [key: string]: string }\n /**\n * Text notes.\n */\n notes?: string\n /**\n * List of financial information (Bank, bank account).\n */\n financialInstitutionInformation?: Array<FinancialInstitutionInformation>\n /**\n * A description of the HCP, meant for the public and in multiple languages.\n */\n descr?: { [key: string]: string }\n /**\n * The invoicing scheme this healthcare party adheres to : 'service fee' or 'flat rate'\n */\n billingType?: string\n type?: string\n contactPerson?: string\n contactPersonHcpId?: string\n supervisorId?: string\n flatRateTarifications?: Array<FlatRateTarification>\n importedData?: { [key: string]: string }\n options?: { [key: string]: string }\n properties?: Array<PropertyStub>\n /**\n * For each couple of HcParties (delegator and delegate), this map contains the exchange AES key. The delegator is always this hcp, the key of the map is the id of the delegate.The AES exchange key is encrypted using RSA twice : once using this hcp public key (index 0 in the Array) and once using the other hcp public key (index 1 in the Array). For a pair of HcParties. Each HcParty always has one AES exchange key for himself.\n */\n hcPartyKeys?: { [key: string]: Array<string> }\n /**\n * Extra AES exchange keys, usually the ones we lost access to at some point. The structure is { publicKey: { delegateId: { myPubKey1: aesExKey_for_this, delegatePubKey1: aesExKey_for_delegate } } }\n */\n aesExchangeKeys?: { [key: string]: { [key: string]: { [key: string]: string } } }\n /**\n * Our private keys encrypted with our public keys. The structure is { publicKey1: { publicKey2: privateKey2_encrypted_with_publicKey1, publicKey3: privateKey3_encrypted_with_publicKey1 } }\n */\n transferKeys?: { [key: string]: { [key: string]: string } }\n /**\n * The privateKeyShamirPartitions are used to share this hcp's private RSA key with a series of other hcParties using Shamir's algorithm. The key of the map is the hcp Id with whom this partition has been shared. The value is \\\"threshold⎮partition in hex\\\" encrypted using the the partition's holder's public RSA key\n */\n privateKeyShamirPartitions?: { [key: string]: string }\n /**\n * The public key of this hcp\n */\n publicKey?: string\n /**\n * The public keys of this actor that are generates using the OAEP Sha-256 standard\n */\n publicKeysForOaepWithSha256?: Array<string>\n}\nexport namespace HealthcareParty {\n export type GenderEnum = 'male' | 'female' | 'indeterminate' | 'changed' | 'changedToMale' | 'changedToFemale' | 'unknown'\n export const GenderEnum = {\n Male: 'male' as GenderEnum,\n Female: 'female' as GenderEnum,\n Indeterminate: 'indeterminate' as GenderEnum,\n Changed: 'changed' as GenderEnum,\n ChangedToMale: 'changedToMale' as GenderEnum,\n ChangedToFemale: 'changedToFemale' as GenderEnum,\n Unknown: 'unknown' as GenderEnum,\n }\n export type StatusesEnum = 'trainee' | 'withconvention' | 'accreditated'\n export const StatusesEnum = {\n Trainee: 'trainee' as StatusesEnum,\n Withconvention: 'withconvention' as StatusesEnum,\n Accreditated: 'accreditated' as StatusesEnum,\n }\n}\n"]}
1
+ {"version":3,"file":"HealthcareParty.js","sourceRoot":"","sources":["../../../icc-api/model/HealthcareParty.ts"],"names":[],"mappings":";;;AAoBA;;GAEG;AACH,+CAAuC;AAEvC,MAAa,eAAe;IAC1B,YAAY,IAAgB;QAC1B,IAAI,WAAW,GAA8B,EAAE,CAAA;QAC/C,IAAI,CAAC,CAAC,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,OAAO,CAAA,EAAE;YACnB,IAAI,OAAO,IAAI,CAAC,OAAO,KAAK,QAAQ,EAAE;gBACpC,WAAW,CAAC,OAAO,GAAG,IAAA,qBAAO,EAAC,IAAI,CAAC,OAAO,CAAC,CAAA;aAC5C;iBAAM,IAAI,IAAI,CAAC,OAAO,YAAY,WAAW,IAAI,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE;gBAClF,WAAW,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAA;aACnC;iBAAM;gBACL,MAAM,IAAI,KAAK,CAAC,6BAA6B,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC,CAAA;aACpE;SACF;QACD,MAAM,CAAC,MAAM,CAAC,IAAe,EAAE,IAAI,EAAE,WAAW,CAAC,CAAA;IACnD,CAAC;CAsLF;AAnMD,0CAmMC;AACD,WAAiB,eAAe;IAEjB,0BAAU,GAAG;QACxB,IAAI,EAAE,MAAoB;QAC1B,MAAM,EAAE,QAAsB;QAC9B,aAAa,EAAE,eAA6B;QAC5C,OAAO,EAAE,SAAuB;QAChC,aAAa,EAAE,eAA6B;QAC5C,eAAe,EAAE,iBAA+B;QAChD,OAAO,EAAE,SAAuB;KACjC,CAAA;IAEY,4BAAY,GAAG;QAC1B,OAAO,EAAE,SAAyB;QAClC,cAAc,EAAE,gBAAgC;QAChD,YAAY,EAAE,cAA8B;KAC7C,CAAA;AACH,CAAC,EAjBgB,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAiB/B","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 { Address } from './Address'\nimport { CodeStub } from './CodeStub'\nimport { FinancialInstitutionInformation } from './FinancialInstitutionInformation'\nimport { FlatRateTarification } from './FlatRateTarification'\nimport { HealthcarePartyHistoryStatus } from './HealthcarePartyHistoryStatus'\nimport { Identifier } from './Identifier'\nimport { PersonName } from './PersonName'\nimport { PropertyStub } from './PropertyStub'\n\n/**\n * This entity is a root level object. It represents a healthcare party. It is serialized in JSON and saved in the underlying icure-healthdata CouchDB database.\n */\nimport { b64_2ab } from './ModelHelper'\nimport { Patient } from './Patient'\nexport class HealthcareParty {\n constructor(json: JSON | any) {\n let pictureData: { picture?: ArrayBuffer } = {}\n if (!!json?.picture) {\n if (typeof json.picture === 'string') {\n pictureData.picture = b64_2ab(json.picture)\n } else if (json.picture instanceof ArrayBuffer || ArrayBuffer.isView(json.picture)) {\n pictureData.picture = json.picture\n } else {\n throw new Error(`Invalid type for picture: ${typeof json.picture}`)\n }\n }\n Object.assign(this as Patient, json, pictureData)\n }\n\n /**\n * the Id of the healthcare party. We encourage using either a v4 UUID or a HL7 Id.\n */\n id?: string\n /**\n * the revision of the healthcare party in the database, used for conflict management / optimistic locking.\n */\n rev?: string\n /**\n * creation timestamp of the object.\n */\n created?: number\n /**\n * last modification timestamp of the object.\n */\n modified?: number\n /**\n * hard delete (unix epoch in ms) timestamp of the object. Filled automatically when deletePatient is called.\n */\n deletionDate?: number\n /**\n * The healthcareparty's identifiers, used by the client to identify uniquely and unambiguously the HCP. However, iCure may not guarantee this uniqueness by itself : This should be done at the client side.\n */\n identifier?: Array<Identifier>\n /**\n * A tag is an item from a codification system that qualifies an entity as being member of a certain class, whatever the value it might have taken. If the tag qualifies the content of a field, it means that whatever the content of the field, the tag will always apply. For example, the label of a field is qualified using a tag. LOINC is a codification system typically used for tags.\n */\n tags?: Array<CodeStub>\n /**\n * A code is an item from a codification system that qualifies the content of this entity. SNOMED-CT, ICPC-2 or ICD-10 codifications systems can be used for codes\n */\n codes?: Array<CodeStub>\n /**\n * The full name of the healthcare party, used mainly when the healthcare party is an organization\n */\n name?: string\n /**\n * the lastname (surname) of the healthcare party. This is the official lastname that should be used for official administrative purposes.\n */\n lastName?: string\n /**\n * the firstname (name) of the healthcare party.\n */\n firstName?: string\n /**\n * the list of all names of the healthcare party, also containing the official full name information. Ordered by preference of use. First element is therefore the official name used for the healthcare party in the application\n */\n names?: Array<PersonName>\n /**\n * the gender of the healthcare party: male, female, indeterminate, changed, changedToMale, changedToFemale, unknown\n */\n gender?: HealthcareParty.GenderEnum\n /**\n * Mr., Ms., Pr., Dr. ...\n */\n civility?: string\n /**\n * The name of the company this healthcare party is member of\n */\n companyName?: string\n /**\n * Medical specialty of the healthcare party\n */\n speciality?: string\n /**\n * Bank Account identifier of the healhtcare party, IBAN, deprecated, use financial institutions instead\n */\n bankAccount?: string\n /**\n * Bank Identifier Code, the SWIFT Address assigned to the bank, use financial institutions instead\n */\n bic?: string\n proxyBankAccount?: string\n proxyBic?: string\n /**\n * All details included in the invoice header\n */\n invoiceHeader?: string\n /**\n * Identifier number for institution type if the healthcare party is an enterprise\n */\n cbe?: string\n /**\n * Identifier number for the institution if the healthcare party is an organization\n */\n ehp?: string\n /**\n * The id of the user that usually handles this healthcare party.\n */\n userId?: string\n /**\n * Id of parent of the user representing the healthcare party.\n */\n parentId?: string\n convention?: number\n /**\n * National Institute for Health and Invalidity Insurance number assigned to healthcare parties (institution or person).\n */\n nihii?: string\n nihiiSpecCode?: string\n /**\n * Social security inscription number.\n */\n ssin?: string\n /**\n * The list of addresses (with address type).\n */\n addresses?: Array<Address>\n /**\n * The list of languages spoken by the patient ordered by fluency (alpha-2 code http://www.loc.gov/standards/iso639-2/ascii_8bits.html).\n */\n languages?: Array<string>\n /**\n * A picture usually saved in JPEG format.\n */\n picture?: ArrayBuffer\n /**\n * The healthcare party's status: 'trainee' or 'withconvention' or 'accredited'\n */\n statuses?: Array<HealthcareParty.StatusesEnum>\n /**\n * The healthcare party's status history\n */\n statusHistory?: Array<HealthcarePartyHistoryStatus>\n /**\n * Medical specialty of the healthcare party codified using FHIR or Kmehr codificaiton scheme\n */\n specialityCodes?: Array<CodeStub>\n /**\n * The type of format for contacting the healthcare party, ex: mobile, phone, email, etc.\n */\n sendFormats?: { [key: string]: string }\n /**\n * Text notes.\n */\n notes?: string\n /**\n * List of financial information (Bank, bank account).\n */\n financialInstitutionInformation?: Array<FinancialInstitutionInformation>\n /**\n * A description of the HCP, meant for the public and in multiple languages.\n */\n descr?: { [key: string]: string }\n /**\n * The invoicing scheme this healthcare party adheres to : 'service fee' or 'flat rate'\n */\n billingType?: string\n type?: string\n contactPerson?: string\n contactPersonHcpId?: string\n supervisorId?: string\n flatRateTarifications?: Array<FlatRateTarification>\n importedData?: { [key: string]: string }\n options?: { [key: string]: string }\n properties?: Array<PropertyStub>\n /**\n * For each couple of HcParties (delegator and delegate), this map contains the exchange AES key. The delegator is always this hcp, the key of the map is the id of the delegate.The AES exchange key is encrypted using RSA twice : once using this hcp public key (index 0 in the Array) and once using the other hcp public key (index 1 in the Array). For a pair of HcParties. Each HcParty always has one AES exchange key for himself.\n */\n hcPartyKeys?: { [key: string]: Array<string> }\n /**\n * Extra AES exchange keys, usually the ones we lost access to at some point. The structure is { publicKey: { delegateId: { myPubKey1: aesExKey_for_this, delegatePubKey1: aesExKey_for_delegate } } }\n */\n aesExchangeKeys?: { [key: string]: { [key: string]: { [key: string]: string } } }\n /**\n * Our private keys encrypted with our public keys. The structure is { publicKey1: { publicKey2: privateKey2_encrypted_with_publicKey1, publicKey3: privateKey3_encrypted_with_publicKey1 } }\n */\n transferKeys?: { [key: string]: { [key: string]: string } }\n /**\n * The privateKeyShamirPartitions are used to share this hcp's private RSA key with a series of other hcParties using Shamir's algorithm. The key of the map is the hcp Id with whom this partition has been shared. The value is \\\"threshold⎮partition in hex\\\" encrypted using the the partition's holder's public RSA key\n */\n privateKeyShamirPartitions?: { [key: string]: string }\n /**\n * The public key of this hcp\n */\n publicKey?: string\n /**\n * The public keys of this actor that are generates using the OAEP Sha-256 standard\n */\n publicKeysForOaepWithSha256?: Array<string>\n}\nexport namespace HealthcareParty {\n export type GenderEnum = 'male' | 'female' | 'indeterminate' | 'changed' | 'changedToMale' | 'changedToFemale' | 'unknown'\n export const GenderEnum = {\n Male: 'male' as GenderEnum,\n Female: 'female' as GenderEnum,\n Indeterminate: 'indeterminate' as GenderEnum,\n Changed: 'changed' as GenderEnum,\n ChangedToMale: 'changedToMale' as GenderEnum,\n ChangedToFemale: 'changedToFemale' as GenderEnum,\n Unknown: 'unknown' as GenderEnum,\n }\n export type StatusesEnum = 'trainee' | 'withconvention' | 'accreditated'\n export const StatusesEnum = {\n Trainee: 'trainee' as StatusesEnum,\n Withconvention: 'withconvention' as StatusesEnum,\n Accreditated: 'accreditated' as StatusesEnum,\n }\n}\n"]}
@@ -8,7 +8,7 @@ const ModelHelper_1 = require("./ModelHelper");
8
8
  class Patient {
9
9
  constructor(json) {
10
10
  let pictureData = {};
11
- if (!!json.picture) {
11
+ if (!!(json === null || json === void 0 ? void 0 : json.picture)) {
12
12
  if (typeof json.picture === 'string') {
13
13
  pictureData.picture = (0, ModelHelper_1.b64_2ab)(json.picture);
14
14
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Patient.js","sourceRoot":"","sources":["../../../icc-api/model/Patient.ts"],"names":[],"mappings":";;;AA0BA;;GAEG;AACH,+CAAuC;AAGvC,MAAa,OAAO;IAClB,YAAY,IAAgB;QAC1B,IAAI,WAAW,GAA8B,EAAE,CAAA;QAC/C,IAAI,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE;YAClB,IAAI,OAAO,IAAI,CAAC,OAAO,KAAK,QAAQ,EAAE;gBACpC,WAAW,CAAC,OAAO,GAAG,IAAA,qBAAO,EAAC,IAAI,CAAC,OAAO,CAAC,CAAA;aAC5C;iBAAM,IAAI,IAAI,CAAC,OAAO,YAAY,WAAW,IAAI,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE;gBAClF,WAAW,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAA;aACnC;iBAAM;gBACL,MAAM,IAAI,KAAK,CAAC,6BAA6B,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC,CAAA;aACpE;SACF;QACD,MAAM,CAAC,MAAM,CAAC,IAAe,EAAE,IAAI,EAAE,WAAW,CAAC,CAAA;IACnD,CAAC;CA8RF;AA3SD,0BA2SC;AACD,WAAiB,OAAO;IAET,kBAAU,GAAG;QACxB,IAAI,EAAE,MAAoB;QAC1B,MAAM,EAAE,QAAsB;QAC9B,aAAa,EAAE,eAA6B;QAC5C,OAAO,EAAE,SAAuB;QAChC,aAAa,EAAE,eAA6B;QAC5C,eAAe,EAAE,iBAA+B;QAChD,OAAO,EAAE,SAAuB;KACjC,CAAA;IAEY,oBAAY,GAAG;QAC1B,IAAI,EAAE,MAAsB;QAC5B,MAAM,EAAE,QAAwB;QAChC,aAAa,EAAE,eAA+B;QAC9C,OAAO,EAAE,SAAyB;QAClC,aAAa,EAAE,eAA+B;QAC9C,eAAe,EAAE,iBAAiC;QAClD,OAAO,EAAE,SAAyB;KACnC,CAAA;IAEY,8BAAsB,GAAG;QACpC,QAAQ,EAAE,UAAoC;QAC9C,KAAK,EAAE,OAAiC;QACxC,WAAW,EAAE,cAAwC;QACrD,OAAO,EAAE,SAAmC;QAC5C,SAAS,EAAE,YAAsC;QACjD,OAAO,EAAE,SAAmC;QAC5C,IAAI,EAAE,MAAgC;KACvC,CAAA;IAgBY,0BAAkB,GAAG;QAChC,MAAM,EAAE,QAA8B;QACtC,QAAQ,EAAE,WAAiC;QAC3C,OAAO,EAAE,SAA+B;QACxC,SAAS,EAAE,WAAiC;QAC5C,QAAQ,EAAE,UAAgC;QAC1C,SAAS,EAAE,WAAiC;QAC5C,OAAO,EAAE,SAA+B;QACxC,OAAO,EAAE,SAA+B;QACxC,WAAW,EAAE,aAAmC;QAChD,OAAO,EAAE,SAA+B;QACxC,QAAQ,EAAE,UAAgC;QAC1C,KAAK,EAAE,OAA6B;QACpC,QAAQ,EAAE,UAAgC;QAC1C,UAAU,EAAE,YAAkC;KAC/C,CAAA;AACH,CAAC,EA9DgB,OAAO,GAAP,eAAO,KAAP,eAAO,QA8DvB","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 { Address } from './Address'\nimport { CodeStub } from './CodeStub'\nimport { Delegation } from './Delegation'\nimport { EmploymentInfo } from './EmploymentInfo'\nimport { FinancialInstitutionInformation } from './FinancialInstitutionInformation'\nimport { Identifier } from './Identifier'\nimport { Insurability } from './Insurability'\nimport { MedicalHouseContract } from './MedicalHouseContract'\nimport { Partnership } from './Partnership'\nimport { PatientHealthCareParty } from './PatientHealthCareParty'\nimport { PersonName } from './PersonName'\nimport { PropertyStub } from './PropertyStub'\nimport { SchoolingInfo } from './SchoolingInfo'\nimport { Annotation } from './Annotation'\n\n/**\n * This entity is a root level object. It represents a patient It is serialized in JSON and saved in the underlying icure-patient CouchDB database.\n */\nimport { b64_2ab } from './ModelHelper'\nimport { SecurityMetadata } from './SecurityMetadata'\nimport { EntityWithDelegationTypeName } from '../../icc-x-api/utils/EntityWithDelegationTypeName'\nexport class Patient {\n constructor(json: JSON | any) {\n let pictureData: { picture?: ArrayBuffer } = {}\n if (!!json.picture) {\n if (typeof json.picture === 'string') {\n pictureData.picture = b64_2ab(json.picture)\n } else if (json.picture instanceof ArrayBuffer || ArrayBuffer.isView(json.picture)) {\n pictureData.picture = json.picture\n } else {\n throw new Error(`Invalid type for picture: ${typeof json.picture}`)\n }\n }\n Object.assign(this as Patient, json, pictureData)\n }\n\n /**\n * the Id of the patient. We encourage using either a v4 UUID or a HL7 Id.\n */\n id?: string\n /**\n * the revision of the patient in the database, used for conflict management / optimistic locking.\n */\n rev?: string\n identifier?: Array<Identifier>\n /**\n * The timestamp (unix epoch in ms) of creation of this entity, will be filled automatically if missing. Not enforced by the application server.\n */\n created?: number\n /**\n * The date (unix epoch in ms) of the latest modification of this entity, will be filled automatically if missing. Not enforced by the application server.\n */\n modified?: number\n /**\n * The id of the User that has created this entity, will be filled automatically if missing. Not enforced by the application server.\n */\n author?: string\n /**\n * The id of the HealthcareParty that is responsible for this entity, will be filled automatically if missing. Not enforced by the application server.\n */\n responsible?: string\n /**\n * A tag is an item from a codification system that qualifies an entity as being member of a certain class, whatever the value it might have taken. If the tag qualifies the content of a field, it means that whatever the content of the field, the tag will always apply. For example, the label of a field is qualified using a tag. LOINC is a codification system typically used for tags.\n */\n tags?: Array<CodeStub>\n /**\n * A code is an item from a codification system that qualifies the content of this entity. SNOMED-CT, ICPC-2 or ICD-10 codifications systems can be used for codes\n */\n codes?: Array<CodeStub>\n /**\n * Soft delete (unix epoch in ms) timestamp of the object.\n */\n endOfLife?: number\n /**\n * hard delete (unix epoch in ms) timestamp of the object. Filled automatically when deletePatient is called.\n */\n deletionDate?: number\n /**\n * the firstname (name) of the patient.\n */\n firstName?: string\n /**\n * the lastname (surname) of the patient. This is the official lastname that should be used for official administrative purposes.\n */\n lastName?: string\n /**\n * the list of all names of the patient, also containing the official full name information. Ordered by preference of use. First element is therefore the official name used for the patient in the application\n */\n names?: Array<PersonName>\n /**\n * the name of the company this patient is member of.\n */\n companyName?: string\n /**\n * the list of languages spoken by the patient ordered by fluency (alpha-2 code http://www.loc.gov/standards/iso639-2/ascii_8bits.html).\n */\n languages?: Array<string>\n /**\n * the list of addresses (with address type).\n */\n addresses?: Array<Address>\n /**\n * Mr., Ms., Pr., Dr. ...\n */\n civility?: string\n /**\n * the gender of the patient: male, female, indeterminate, changed, changedToMale, changedToFemale, unknown\n */\n gender?: Patient.GenderEnum\n /**\n * the birth sex of the patient: male, female, indeterminate, unknown\n */\n birthSex?: Patient.BirthSexEnum\n /**\n * The id of the patient this patient has been merged with.\n */\n mergeToPatientId?: string\n /**\n * The ids of the patients that have been merged inside this patient.\n */\n mergedIds?: Array<string>\n /**\n * An alias of the person, nickname, ...\n */\n alias?: string\n /**\n * Is the patient active (boolean).\n */\n active?: boolean\n /**\n * When not active, the reason for deactivation.\n */\n deactivationReason?: Patient.DeactivationReasonEnum\n /**\n * Deactivation date of the patient\n */\n deactivationDate?: number\n /**\n * Social security inscription number.\n */\n ssin?: string\n /**\n * Lastname at birth (can be different of the current name), depending on the country, must be used to design the patient .\n */\n maidenName?: string\n /**\n * Lastname of the spouse for a married woman, depending on the country, can be used to design the patient.\n */\n spouseName?: string\n /**\n * Lastname of the partner, should not be used to design the patient.\n */\n partnerName?: string\n /**\n * any of `single`, `in_couple`, `married`, `separated`, `divorced`, `divorcing`, `widowed`, `widower`, `complicated`, `unknown`, `contract`, `other`.\n */\n personalStatus?: Patient.PersonalStatusEnum\n /**\n * The birthdate encoded as a fuzzy date on 8 positions (YYYYMMDD) MM and/or DD can be set to 00 if unknown (19740000 is a valid date).\n */\n dateOfBirth?: number\n /**\n * The date of death encoded as a fuzzy date on 8 positions (YYYYMMDD) MM and/or DD can be set to 00 if unknown (19740000 is a valid date).\n */\n dateOfDeath?: number\n /**\n * Timestamp of the latest validation of the eID of the person..\n */\n timestampOfLatestEidReading?: number\n /**\n * The place of birth.\n */\n placeOfBirth?: string\n /**\n * The place of death.\n */\n placeOfDeath?: string\n /**\n * Is the patient deceased.\n */\n deceased?: boolean\n /**\n * The level of education (college degree, undergraduate, phd).\n */\n education?: string\n /**\n * The current professional activity.\n */\n profession?: string\n /**\n * A text note (can be confidential, encrypted by default).\n * @deprecated use notes instead with proper tags\n */\n note?: string\n /**\n * An administrative note, not confidential.\n * @deprecated use notes instead with proper tags\n */\n administrativeNote?: string\n /**\n * A list of localized notes.\n */\n notes?: Annotation[]\n /**\n * The nationality of the patient.\n */\n nationality?: string\n /**\n * The race of the patient.\n */\n race?: string\n /**\n * The ethnicity of the patient.\n */\n ethnicity?: string\n /**\n * The id of the user that usually handles this patient.\n */\n preferredUserId?: string\n /**\n * A picture usually saved in JPEG format.\n */\n picture?: ArrayBuffer\n /**\n * An external (from another source) id with no guarantee or requirement for unicity .\n */\n externalId?: string\n /**\n * List of insurance coverages (of class Insurability, see below).\n */\n insurabilities?: Array<Insurability>\n /**\n * List of partners, or persons of contact (of class Partnership, see below).\n */\n partnerships?: Array<Partnership>\n /**\n * Links (usually for therapeutic reasons) between this patient and healthcare parties (of class PatientHealthcareParty).\n */\n patientHealthCareParties?: Array<PatientHealthCareParty>\n /**\n * Financial information (Bank, bank account) used to reimburse the patient.\n */\n financialInstitutionInformation?: Array<FinancialInstitutionInformation>\n /**\n * Contracts between the patient and the healthcare entity.\n */\n medicalHouseContracts?: Array<MedicalHouseContract>\n /**\n * Codified list of professions exercised by this patient.\n */\n patientProfessions?: Array<CodeStub>\n /**\n * Extra parameters\n */\n parameters?: { [key: string]: Array<string> }\n /**\n * Extra properties\n */\n properties?: Array<PropertyStub>\n /**\n * For each couple of HcParties (delegator and delegate), this map contains the exchange AES key. The delegator is always this hcp, the key of the map is the id of the delegate.The AES exchange key is encrypted using RSA twice : once using this hcp public key (index 0 in the Array) and once using the other hcp public key (index 1 in the Array). For a pair of HcParties. Each HcParty always has one AES exchange key for himself.\n */\n hcPartyKeys?: { [key: string]: Array<string> }\n /**\n * Extra AES exchange keys, usually the ones we lost access to at some point. The structure is { publicKey: { delegateId: { myPubKey1: aesExKey_for_this, delegatePubKey1: aesExKey_for_delegate } } }\n */\n aesExchangeKeys?: { [key: string]: { [key: string]: { [key: string]: string } } }\n /**\n * Our private keys encrypted with our public keys. The structure is { publicKey1: { publicKey2: privateKey2_encrypted_with_publicKey1, publicKey3: privateKey3_encrypted_with_publicKey1 } }\n */\n transferKeys?: { [key: string]: { [key: string]: string } }\n /**\n * The privateKeyShamirPartitions are used to share this hcp's private RSA key with a series of other hcParties using Shamir's algorithm. The key of the map is the hcp Id with whom this partition has been shared. The value is \\\"threshold⎮partition in hex\\\" encrypted using the the partition's holder's public RSA key\n */\n privateKeyShamirPartitions?: { [key: string]: string }\n /**\n * The public key of this hcp\n */\n publicKey?: string\n /**\n * The public keys of this actor that are generates using the OAEP Sha-256 standard\n */\n publicKeysForOaepWithSha256?: Array<string>\n /**\n * The secretForeignKeys are filled at the to many end of a one to many relationship (for example inside Contact for the Patient -> Contacts relationship). Used when we want to find all contacts for a specific patient. These keys are in clear. You can have several to partition the medical document space.\n */\n secretForeignKeys?: Array<string>\n /**\n * The secretForeignKeys are filled at the to many end of a one to many relationship (for example inside Contact for the Patient -> Contacts relationship). Used when we want to find the patient for a specific contact. These keys are the encrypted id (using the hcParty key for the delegate) that can be found in clear inside the patient. ids encrypted using the hcParty keys.\n */\n cryptedForeignKeys?: { [key: string]: Array<Delegation> }\n /**\n * When a document is created, the responsible generates a cryptographically random master key (never to be used for something else than referencing from other entities). He/she encrypts it using his own AES exchange key and stores it as a delegation. The responsible is thus always in the delegations as well\n */\n delegations?: { [key: string]: Array<Delegation> }\n /**\n * When a document needs to be encrypted, the responsible generates a cryptographically random master key (different from the delegation key, never to appear in clear anywhere in the db. He/she encrypts it using his own AES exchange key and stores it as a delegation\n */\n encryptionKeys?: { [key: string]: Array<Delegation> }\n /**\n * The base64 encoded data of this object, formatted as JSON and encrypted in AES using the random master key from encryptionKeys.\n */\n encryptedSelf?: string\n /**\n * The id of the medical location where this entity was created.\n */\n medicalLocationId?: string\n nonDuplicateIds?: Array<string>\n encryptedAdministrativesDocuments?: Array<string>\n comment?: string\n warning?: string\n fatherBirthCountry?: CodeStub\n birthCountry?: CodeStub\n nativeCountry?: CodeStub\n socialStatus?: CodeStub\n mainSourceOfIncome?: CodeStub\n schoolingInfos?: Array<SchoolingInfo>\n employementInfos?: Array<EmploymentInfo>\n securityMetadata?: SecurityMetadata\n \n}\nexport namespace Patient {\n export type GenderEnum = 'male' | 'female' | 'indeterminate' | 'changed' | 'changedToMale' | 'changedToFemale' | 'unknown'\n export const GenderEnum = {\n Male: 'male' as GenderEnum,\n Female: 'female' as GenderEnum,\n Indeterminate: 'indeterminate' as GenderEnum,\n Changed: 'changed' as GenderEnum,\n ChangedToMale: 'changedToMale' as GenderEnum,\n ChangedToFemale: 'changedToFemale' as GenderEnum,\n Unknown: 'unknown' as GenderEnum,\n }\n export type BirthSexEnum = 'male' | 'female' | 'indeterminate' | 'changed' | 'changedToMale' | 'changedToFemale' | 'unknown'\n export const BirthSexEnum = {\n Male: 'male' as BirthSexEnum,\n Female: 'female' as BirthSexEnum,\n Indeterminate: 'indeterminate' as BirthSexEnum,\n Changed: 'changed' as BirthSexEnum,\n ChangedToMale: 'changedToMale' as BirthSexEnum,\n ChangedToFemale: 'changedToFemale' as BirthSexEnum,\n Unknown: 'unknown' as BirthSexEnum,\n }\n export type DeactivationReasonEnum = 'deceased' | 'moved' | 'other_doctor' | 'retired' | 'no_contact' | 'unknown' | 'none'\n export const DeactivationReasonEnum = {\n Deceased: 'deceased' as DeactivationReasonEnum,\n Moved: 'moved' as DeactivationReasonEnum,\n OtherDoctor: 'other_doctor' as DeactivationReasonEnum,\n Retired: 'retired' as DeactivationReasonEnum,\n NoContact: 'no_contact' as DeactivationReasonEnum,\n Unknown: 'unknown' as DeactivationReasonEnum,\n None: 'none' as DeactivationReasonEnum,\n }\n export type PersonalStatusEnum =\n | 'single'\n | 'in_couple'\n | 'married'\n | 'separated'\n | 'divorced'\n | 'divorcing'\n | 'widowed'\n | 'widower'\n | 'complicated'\n | 'unknown'\n | 'contract'\n | 'other'\n | 'annulled'\n | 'polygamous'\n export const PersonalStatusEnum = {\n Single: 'single' as PersonalStatusEnum,\n InCouple: 'in_couple' as PersonalStatusEnum,\n Married: 'married' as PersonalStatusEnum,\n Separated: 'separated' as PersonalStatusEnum,\n Divorced: 'divorced' as PersonalStatusEnum,\n Divorcing: 'divorcing' as PersonalStatusEnum,\n Widowed: 'widowed' as PersonalStatusEnum,\n Widower: 'widower' as PersonalStatusEnum,\n Complicated: 'complicated' as PersonalStatusEnum,\n Unknown: 'unknown' as PersonalStatusEnum,\n Contract: 'contract' as PersonalStatusEnum,\n Other: 'other' as PersonalStatusEnum,\n Annulled: 'annulled' as PersonalStatusEnum,\n Polygamous: 'polygamous' as PersonalStatusEnum,\n }\n}\n"]}
1
+ {"version":3,"file":"Patient.js","sourceRoot":"","sources":["../../../icc-api/model/Patient.ts"],"names":[],"mappings":";;;AA0BA;;GAEG;AACH,+CAAuC;AAGvC,MAAa,OAAO;IAClB,YAAY,IAAgB;QAC1B,IAAI,WAAW,GAA8B,EAAE,CAAA;QAC/C,IAAI,CAAC,CAAC,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,OAAO,CAAA,EAAE;YACnB,IAAI,OAAO,IAAI,CAAC,OAAO,KAAK,QAAQ,EAAE;gBACpC,WAAW,CAAC,OAAO,GAAG,IAAA,qBAAO,EAAC,IAAI,CAAC,OAAO,CAAC,CAAA;aAC5C;iBAAM,IAAI,IAAI,CAAC,OAAO,YAAY,WAAW,IAAI,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE;gBAClF,WAAW,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAA;aACnC;iBAAM;gBACL,MAAM,IAAI,KAAK,CAAC,6BAA6B,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC,CAAA;aACpE;SACF;QACD,MAAM,CAAC,MAAM,CAAC,IAAe,EAAE,IAAI,EAAE,WAAW,CAAC,CAAA;IACnD,CAAC;CA6RF;AA1SD,0BA0SC;AACD,WAAiB,OAAO;IAET,kBAAU,GAAG;QACxB,IAAI,EAAE,MAAoB;QAC1B,MAAM,EAAE,QAAsB;QAC9B,aAAa,EAAE,eAA6B;QAC5C,OAAO,EAAE,SAAuB;QAChC,aAAa,EAAE,eAA6B;QAC5C,eAAe,EAAE,iBAA+B;QAChD,OAAO,EAAE,SAAuB;KACjC,CAAA;IAEY,oBAAY,GAAG;QAC1B,IAAI,EAAE,MAAsB;QAC5B,MAAM,EAAE,QAAwB;QAChC,aAAa,EAAE,eAA+B;QAC9C,OAAO,EAAE,SAAyB;QAClC,aAAa,EAAE,eAA+B;QAC9C,eAAe,EAAE,iBAAiC;QAClD,OAAO,EAAE,SAAyB;KACnC,CAAA;IAEY,8BAAsB,GAAG;QACpC,QAAQ,EAAE,UAAoC;QAC9C,KAAK,EAAE,OAAiC;QACxC,WAAW,EAAE,cAAwC;QACrD,OAAO,EAAE,SAAmC;QAC5C,SAAS,EAAE,YAAsC;QACjD,OAAO,EAAE,SAAmC;QAC5C,IAAI,EAAE,MAAgC;KACvC,CAAA;IAgBY,0BAAkB,GAAG;QAChC,MAAM,EAAE,QAA8B;QACtC,QAAQ,EAAE,WAAiC;QAC3C,OAAO,EAAE,SAA+B;QACxC,SAAS,EAAE,WAAiC;QAC5C,QAAQ,EAAE,UAAgC;QAC1C,SAAS,EAAE,WAAiC;QAC5C,OAAO,EAAE,SAA+B;QACxC,OAAO,EAAE,SAA+B;QACxC,WAAW,EAAE,aAAmC;QAChD,OAAO,EAAE,SAA+B;QACxC,QAAQ,EAAE,UAAgC;QAC1C,KAAK,EAAE,OAA6B;QACpC,QAAQ,EAAE,UAAgC;QAC1C,UAAU,EAAE,YAAkC;KAC/C,CAAA;AACH,CAAC,EA9DgB,OAAO,GAAP,eAAO,KAAP,eAAO,QA8DvB","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 { Address } from './Address'\nimport { CodeStub } from './CodeStub'\nimport { Delegation } from './Delegation'\nimport { EmploymentInfo } from './EmploymentInfo'\nimport { FinancialInstitutionInformation } from './FinancialInstitutionInformation'\nimport { Identifier } from './Identifier'\nimport { Insurability } from './Insurability'\nimport { MedicalHouseContract } from './MedicalHouseContract'\nimport { Partnership } from './Partnership'\nimport { PatientHealthCareParty } from './PatientHealthCareParty'\nimport { PersonName } from './PersonName'\nimport { PropertyStub } from './PropertyStub'\nimport { SchoolingInfo } from './SchoolingInfo'\nimport { Annotation } from './Annotation'\n\n/**\n * This entity is a root level object. It represents a patient It is serialized in JSON and saved in the underlying icure-patient CouchDB database.\n */\nimport { b64_2ab } from './ModelHelper'\nimport { SecurityMetadata } from './SecurityMetadata'\nimport { EntityWithDelegationTypeName } from '../../icc-x-api/utils/EntityWithDelegationTypeName'\nexport class Patient {\n constructor(json: JSON | any) {\n let pictureData: { picture?: ArrayBuffer } = {}\n if (!!json?.picture) {\n if (typeof json.picture === 'string') {\n pictureData.picture = b64_2ab(json.picture)\n } else if (json.picture instanceof ArrayBuffer || ArrayBuffer.isView(json.picture)) {\n pictureData.picture = json.picture\n } else {\n throw new Error(`Invalid type for picture: ${typeof json.picture}`)\n }\n }\n Object.assign(this as Patient, json, pictureData)\n }\n\n /**\n * the Id of the patient. We encourage using either a v4 UUID or a HL7 Id.\n */\n id?: string\n /**\n * the revision of the patient in the database, used for conflict management / optimistic locking.\n */\n rev?: string\n identifier?: Array<Identifier>\n /**\n * The timestamp (unix epoch in ms) of creation of this entity, will be filled automatically if missing. Not enforced by the application server.\n */\n created?: number\n /**\n * The date (unix epoch in ms) of the latest modification of this entity, will be filled automatically if missing. Not enforced by the application server.\n */\n modified?: number\n /**\n * The id of the User that has created this entity, will be filled automatically if missing. Not enforced by the application server.\n */\n author?: string\n /**\n * The id of the HealthcareParty that is responsible for this entity, will be filled automatically if missing. Not enforced by the application server.\n */\n responsible?: string\n /**\n * A tag is an item from a codification system that qualifies an entity as being member of a certain class, whatever the value it might have taken. If the tag qualifies the content of a field, it means that whatever the content of the field, the tag will always apply. For example, the label of a field is qualified using a tag. LOINC is a codification system typically used for tags.\n */\n tags?: Array<CodeStub>\n /**\n * A code is an item from a codification system that qualifies the content of this entity. SNOMED-CT, ICPC-2 or ICD-10 codifications systems can be used for codes\n */\n codes?: Array<CodeStub>\n /**\n * Soft delete (unix epoch in ms) timestamp of the object.\n */\n endOfLife?: number\n /**\n * hard delete (unix epoch in ms) timestamp of the object. Filled automatically when deletePatient is called.\n */\n deletionDate?: number\n /**\n * the firstname (name) of the patient.\n */\n firstName?: string\n /**\n * the lastname (surname) of the patient. This is the official lastname that should be used for official administrative purposes.\n */\n lastName?: string\n /**\n * the list of all names of the patient, also containing the official full name information. Ordered by preference of use. First element is therefore the official name used for the patient in the application\n */\n names?: Array<PersonName>\n /**\n * the name of the company this patient is member of.\n */\n companyName?: string\n /**\n * the list of languages spoken by the patient ordered by fluency (alpha-2 code http://www.loc.gov/standards/iso639-2/ascii_8bits.html).\n */\n languages?: Array<string>\n /**\n * the list of addresses (with address type).\n */\n addresses?: Array<Address>\n /**\n * Mr., Ms., Pr., Dr. ...\n */\n civility?: string\n /**\n * the gender of the patient: male, female, indeterminate, changed, changedToMale, changedToFemale, unknown\n */\n gender?: Patient.GenderEnum\n /**\n * the birth sex of the patient: male, female, indeterminate, unknown\n */\n birthSex?: Patient.BirthSexEnum\n /**\n * The id of the patient this patient has been merged with.\n */\n mergeToPatientId?: string\n /**\n * The ids of the patients that have been merged inside this patient.\n */\n mergedIds?: Array<string>\n /**\n * An alias of the person, nickname, ...\n */\n alias?: string\n /**\n * Is the patient active (boolean).\n */\n active?: boolean\n /**\n * When not active, the reason for deactivation.\n */\n deactivationReason?: Patient.DeactivationReasonEnum\n /**\n * Deactivation date of the patient\n */\n deactivationDate?: number\n /**\n * Social security inscription number.\n */\n ssin?: string\n /**\n * Lastname at birth (can be different of the current name), depending on the country, must be used to design the patient .\n */\n maidenName?: string\n /**\n * Lastname of the spouse for a married woman, depending on the country, can be used to design the patient.\n */\n spouseName?: string\n /**\n * Lastname of the partner, should not be used to design the patient.\n */\n partnerName?: string\n /**\n * any of `single`, `in_couple`, `married`, `separated`, `divorced`, `divorcing`, `widowed`, `widower`, `complicated`, `unknown`, `contract`, `other`.\n */\n personalStatus?: Patient.PersonalStatusEnum\n /**\n * The birthdate encoded as a fuzzy date on 8 positions (YYYYMMDD) MM and/or DD can be set to 00 if unknown (19740000 is a valid date).\n */\n dateOfBirth?: number\n /**\n * The date of death encoded as a fuzzy date on 8 positions (YYYYMMDD) MM and/or DD can be set to 00 if unknown (19740000 is a valid date).\n */\n dateOfDeath?: number\n /**\n * Timestamp of the latest validation of the eID of the person..\n */\n timestampOfLatestEidReading?: number\n /**\n * The place of birth.\n */\n placeOfBirth?: string\n /**\n * The place of death.\n */\n placeOfDeath?: string\n /**\n * Is the patient deceased.\n */\n deceased?: boolean\n /**\n * The level of education (college degree, undergraduate, phd).\n */\n education?: string\n /**\n * The current professional activity.\n */\n profession?: string\n /**\n * A text note (can be confidential, encrypted by default).\n * @deprecated use notes instead with proper tags\n */\n note?: string\n /**\n * An administrative note, not confidential.\n * @deprecated use notes instead with proper tags\n */\n administrativeNote?: string\n /**\n * A list of localized notes.\n */\n notes?: Annotation[]\n /**\n * The nationality of the patient.\n */\n nationality?: string\n /**\n * The race of the patient.\n */\n race?: string\n /**\n * The ethnicity of the patient.\n */\n ethnicity?: string\n /**\n * The id of the user that usually handles this patient.\n */\n preferredUserId?: string\n /**\n * A picture usually saved in JPEG format.\n */\n picture?: ArrayBuffer\n /**\n * An external (from another source) id with no guarantee or requirement for unicity .\n */\n externalId?: string\n /**\n * List of insurance coverages (of class Insurability, see below).\n */\n insurabilities?: Array<Insurability>\n /**\n * List of partners, or persons of contact (of class Partnership, see below).\n */\n partnerships?: Array<Partnership>\n /**\n * Links (usually for therapeutic reasons) between this patient and healthcare parties (of class PatientHealthcareParty).\n */\n patientHealthCareParties?: Array<PatientHealthCareParty>\n /**\n * Financial information (Bank, bank account) used to reimburse the patient.\n */\n financialInstitutionInformation?: Array<FinancialInstitutionInformation>\n /**\n * Contracts between the patient and the healthcare entity.\n */\n medicalHouseContracts?: Array<MedicalHouseContract>\n /**\n * Codified list of professions exercised by this patient.\n */\n patientProfessions?: Array<CodeStub>\n /**\n * Extra parameters\n */\n parameters?: { [key: string]: Array<string> }\n /**\n * Extra properties\n */\n properties?: Array<PropertyStub>\n /**\n * For each couple of HcParties (delegator and delegate), this map contains the exchange AES key. The delegator is always this hcp, the key of the map is the id of the delegate.The AES exchange key is encrypted using RSA twice : once using this hcp public key (index 0 in the Array) and once using the other hcp public key (index 1 in the Array). For a pair of HcParties. Each HcParty always has one AES exchange key for himself.\n */\n hcPartyKeys?: { [key: string]: Array<string> }\n /**\n * Extra AES exchange keys, usually the ones we lost access to at some point. The structure is { publicKey: { delegateId: { myPubKey1: aesExKey_for_this, delegatePubKey1: aesExKey_for_delegate } } }\n */\n aesExchangeKeys?: { [key: string]: { [key: string]: { [key: string]: string } } }\n /**\n * Our private keys encrypted with our public keys. The structure is { publicKey1: { publicKey2: privateKey2_encrypted_with_publicKey1, publicKey3: privateKey3_encrypted_with_publicKey1 } }\n */\n transferKeys?: { [key: string]: { [key: string]: string } }\n /**\n * The privateKeyShamirPartitions are used to share this hcp's private RSA key with a series of other hcParties using Shamir's algorithm. The key of the map is the hcp Id with whom this partition has been shared. The value is \\\"threshold⎮partition in hex\\\" encrypted using the the partition's holder's public RSA key\n */\n privateKeyShamirPartitions?: { [key: string]: string }\n /**\n * The public key of this hcp\n */\n publicKey?: string\n /**\n * The public keys of this actor that are generates using the OAEP Sha-256 standard\n */\n publicKeysForOaepWithSha256?: Array<string>\n /**\n * The secretForeignKeys are filled at the to many end of a one to many relationship (for example inside Contact for the Patient -> Contacts relationship). Used when we want to find all contacts for a specific patient. These keys are in clear. You can have several to partition the medical document space.\n */\n secretForeignKeys?: Array<string>\n /**\n * The secretForeignKeys are filled at the to many end of a one to many relationship (for example inside Contact for the Patient -> Contacts relationship). Used when we want to find the patient for a specific contact. These keys are the encrypted id (using the hcParty key for the delegate) that can be found in clear inside the patient. ids encrypted using the hcParty keys.\n */\n cryptedForeignKeys?: { [key: string]: Array<Delegation> }\n /**\n * When a document is created, the responsible generates a cryptographically random master key (never to be used for something else than referencing from other entities). He/she encrypts it using his own AES exchange key and stores it as a delegation. The responsible is thus always in the delegations as well\n */\n delegations?: { [key: string]: Array<Delegation> }\n /**\n * When a document needs to be encrypted, the responsible generates a cryptographically random master key (different from the delegation key, never to appear in clear anywhere in the db. He/she encrypts it using his own AES exchange key and stores it as a delegation\n */\n encryptionKeys?: { [key: string]: Array<Delegation> }\n /**\n * The base64 encoded data of this object, formatted as JSON and encrypted in AES using the random master key from encryptionKeys.\n */\n encryptedSelf?: string\n /**\n * The id of the medical location where this entity was created.\n */\n medicalLocationId?: string\n nonDuplicateIds?: Array<string>\n encryptedAdministrativesDocuments?: Array<string>\n comment?: string\n warning?: string\n fatherBirthCountry?: CodeStub\n birthCountry?: CodeStub\n nativeCountry?: CodeStub\n socialStatus?: CodeStub\n mainSourceOfIncome?: CodeStub\n schoolingInfos?: Array<SchoolingInfo>\n employementInfos?: Array<EmploymentInfo>\n securityMetadata?: SecurityMetadata\n}\nexport namespace Patient {\n export type GenderEnum = 'male' | 'female' | 'indeterminate' | 'changed' | 'changedToMale' | 'changedToFemale' | 'unknown'\n export const GenderEnum = {\n Male: 'male' as GenderEnum,\n Female: 'female' as GenderEnum,\n Indeterminate: 'indeterminate' as GenderEnum,\n Changed: 'changed' as GenderEnum,\n ChangedToMale: 'changedToMale' as GenderEnum,\n ChangedToFemale: 'changedToFemale' as GenderEnum,\n Unknown: 'unknown' as GenderEnum,\n }\n export type BirthSexEnum = 'male' | 'female' | 'indeterminate' | 'changed' | 'changedToMale' | 'changedToFemale' | 'unknown'\n export const BirthSexEnum = {\n Male: 'male' as BirthSexEnum,\n Female: 'female' as BirthSexEnum,\n Indeterminate: 'indeterminate' as BirthSexEnum,\n Changed: 'changed' as BirthSexEnum,\n ChangedToMale: 'changedToMale' as BirthSexEnum,\n ChangedToFemale: 'changedToFemale' as BirthSexEnum,\n Unknown: 'unknown' as BirthSexEnum,\n }\n export type DeactivationReasonEnum = 'deceased' | 'moved' | 'other_doctor' | 'retired' | 'no_contact' | 'unknown' | 'none'\n export const DeactivationReasonEnum = {\n Deceased: 'deceased' as DeactivationReasonEnum,\n Moved: 'moved' as DeactivationReasonEnum,\n OtherDoctor: 'other_doctor' as DeactivationReasonEnum,\n Retired: 'retired' as DeactivationReasonEnum,\n NoContact: 'no_contact' as DeactivationReasonEnum,\n Unknown: 'unknown' as DeactivationReasonEnum,\n None: 'none' as DeactivationReasonEnum,\n }\n export type PersonalStatusEnum =\n | 'single'\n | 'in_couple'\n | 'married'\n | 'separated'\n | 'divorced'\n | 'divorcing'\n | 'widowed'\n | 'widower'\n | 'complicated'\n | 'unknown'\n | 'contract'\n | 'other'\n | 'annulled'\n | 'polygamous'\n export const PersonalStatusEnum = {\n Single: 'single' as PersonalStatusEnum,\n InCouple: 'in_couple' as PersonalStatusEnum,\n Married: 'married' as PersonalStatusEnum,\n Separated: 'separated' as PersonalStatusEnum,\n Divorced: 'divorced' as PersonalStatusEnum,\n Divorcing: 'divorcing' as PersonalStatusEnum,\n Widowed: 'widowed' as PersonalStatusEnum,\n Widower: 'widower' as PersonalStatusEnum,\n Complicated: 'complicated' as PersonalStatusEnum,\n Unknown: 'unknown' as PersonalStatusEnum,\n Contract: 'contract' as PersonalStatusEnum,\n Other: 'other' as PersonalStatusEnum,\n Annulled: 'annulled' as PersonalStatusEnum,\n Polygamous: 'polygamous' as PersonalStatusEnum,\n }\n}\n"]}
@@ -9,6 +9,7 @@ import { ShareResult } from '../utils/ShareResult';
9
9
  import { MinimalEntityBulkShareResult } from '../../icc-api/model/requests/MinimalEntityBulkShareResult';
10
10
  import { EncryptedFieldsManifest } from '../utils';
11
11
  import { BulkShareOrUpdateMetadataParams } from '../../icc-api/model/requests/BulkShareOrUpdateMetadataParams';
12
+ import { SecretIdUseOption } from './SecretIdUseOption';
12
13
  /**
13
14
  * @internal this interface is meant only for internal use and may be changed without notice.
14
15
  * Gives access to several functions to access encrypted entities metadata.
@@ -93,6 +94,7 @@ export interface ExtendedApisUtils {
93
94
  * @return if the entity has no encryption metadata and can be safely initialised using .
94
95
  */
95
96
  hasEmptyEncryptionMetadata(entity: EncryptedEntity): boolean;
97
+ resolveSecretIdUseOptions(entity: EncryptedEntityWithType, option: SecretIdUseOption): Promise<string[]>;
96
98
  /**
97
99
  * Initializes encryption metadata for an entity. This includes the encrypted secret id, owning entity id, encryption key for the entity, and
98
100
  * the clear text secret foreign key of the parent entity.
@@ -100,7 +102,7 @@ export interface ExtendedApisUtils {
100
102
  * @param entity entity which requires encryption metadata initialisation.
101
103
  * @param entityType type of the entity.
102
104
  * @param owningEntity id of the owning entity, if any (e.g. patient id for Contact/HealtchareElement, message id for Document, ...).
103
- * @param owningEntitySecretId secret id of the parent entity, to use in the secret foreign keys for the provided entity, if any.
105
+ * @param owningEntitySecretIds secret id of the parent entity, to use in the secret foreign keys for the provided entity, if any.
104
106
  * @param initialiseEncryptionKey if false this method will not initialize an encryption key for the entity. Use only for entities which use
105
107
  * delegations for access control but don't actually have any encrypted content.
106
108
  * HealthcareElement).
@@ -108,7 +110,7 @@ export interface ExtendedApisUtils {
108
110
  * @throws if the entity already has non-empty values for encryption metadata.
109
111
  * @return an updated copy of the entity.
110
112
  */
111
- entityWithInitialisedEncryptedMetadata<T extends EncryptedEntity>(entity: T, entityType: EntityWithDelegationTypeName, owningEntity: string | undefined, owningEntitySecretId: string | undefined, initialiseEncryptionKey: boolean, autoDelegations: {
113
+ entityWithInitialisedEncryptedMetadata<T extends EncryptedEntity>(entity: T, entityType: EntityWithDelegationTypeName, owningEntity: string | undefined, owningEntitySecretIds: string[] | undefined, initialiseEncryptionKey: boolean, autoDelegations: {
112
114
  [p: string]: SecureDelegation.AccessLevelEnum;
113
115
  }): Promise<{
114
116
  updatedEntity: T;
@@ -330,4 +332,47 @@ export interface ExtendedApisUtils {
330
332
  }[]) => Promise<{
331
333
  success: T;
332
334
  } | null>): Promise<Map<string, T>>;
335
+ /**
336
+ * Ensures that the current data owner has access to a confidential secret id for the provided entity: this is an id that is known to the data owner
337
+ * but is not known by any of his parents. If there is currently no confidential secret id for this entity the method returns a copy of the entity
338
+ * with a new confidential secret id for the current data owner (the entity in the database won't be updated), else this method returns undefined.
339
+ * New confidential secret ids will have an appropriate tag, but existing confidential secret ids may not necessarily have it.
340
+ * @param entity an entity which needs to have a confidential secret id for the current data owner
341
+ * @param entityType the type of the entity
342
+ * @param doRequestBulkShareOrUpdate perform the request to share or update an entity encrypted metadata on the cloud API (and save to DB).
343
+ * @return undefined if the entity already had a confidential secret id for the current user, or the updated AND SAVED entity with the new
344
+ * confidential secret id.
345
+ */
346
+ initialiseConfidentialSecretId<T extends EncryptedEntity>(entity: T, entityType: EntityWithDelegationTypeName, doRequestBulkShareOrUpdate: (request: BulkShareOrUpdateMetadataParams) => Promise<EntityBulkShareResult<T>[]>): Promise<T | undefined>;
347
+ /**
348
+ * Get an existing confidential secret id of the provided entity for the provided data owner (current data owner by default). A confidential secret
349
+ * id is a secret id known by the data owner but not known by any of his parents: note however that children will know confidential secret ids.
350
+ * @param entity an entity for which you want to retrieve the confidential secret id.
351
+ * @param dataOwnerId (current data owner by default) a data owner for which you want to get a confidential secret id.
352
+ * @return the confidential secret id or undefined if there is no confidential secret id for the provided data owner.
353
+ */
354
+ getConfidentialSecretId(entity: EncryptedEntityWithType, dataOwnerId?: string): Promise<string | undefined>;
355
+ /**
356
+ * Get all existing confidential secret ids of the provided entity for the provided data owner (current data owner by default). A confidential secret
357
+ * id is a secret id known by the data owner but not known by any of his parents: note however that children will know confidential secret ids.
358
+ * @param entity an entity for which you want to retrieve the confidential secret id.
359
+ * @param dataOwnerId (current data owner by default) a data owner for which you want to get a confidential secret id.
360
+ * @return the confidential secret ids for the data owner (may be empty).
361
+ */
362
+ getConfidentialSecretIds(entity: EncryptedEntityWithType, dataOwnerId?: string): Promise<string[]>;
363
+ /**
364
+ * Gets a secret id known by the topmost parent of the current data owner hierarchy. If there is multiple secret ids shared with the topmost parent
365
+ * there is no guarantee on which one will be chosen.
366
+ * @param entity an entity.
367
+ * @return a secret id known by the topmost parent of the current data owner hierarchy, or undefined if there is no secret id currently available
368
+ * for the topmost parent.
369
+ */
370
+ getAnySecretIdSharedWithParents(entity: EncryptedEntityWithType): Promise<string | undefined>;
371
+ /**
372
+ * Gets all secret ids known by the topmost parent of the current data owner hierarchy (or all secret ids known by the current data owner if he is
373
+ * not part of any data owner hierarchy).
374
+ * @param entity an entity.
375
+ * @return all secret ids known by the topmost parent of the current data owner hierarchy, may be empty.
376
+ */
377
+ getSecretIdsSharedWithParents(entity: EncryptedEntityWithType): Promise<string[]>;
333
378
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ExtendedApisUtils.js","sourceRoot":"","sources":["../../../icc-x-api/crypto/ExtendedApisUtils.ts"],"names":[],"mappings":"","sourcesContent":["import { EncryptedEntity, EncryptedEntityStub } from '../../icc-api/model/models'\nimport { EncryptedEntityWithType, EntityWithDelegationTypeName } from '../utils/EntityWithDelegationTypeName'\nimport { SecureDelegation } from '../../icc-api/model/SecureDelegation'\nimport AccessLevelEnum = SecureDelegation.AccessLevelEnum\nimport { EntityShareOrMetadataUpdateRequest } from '../../icc-api/model/requests/EntityShareOrMetadataUpdateRequest'\nimport { EntityShareRequest } from '../../icc-api/model/requests/EntityShareRequest'\nimport { EntityBulkShareResult } from '../../icc-api/model/requests/EntityBulkShareResult'\nimport RequestedPermissionEnum = EntityShareRequest.RequestedPermissionEnum\nimport { ShareMetadataBehaviour } from './ShareMetadataBehaviour'\nimport { ShareResult } from '../utils/ShareResult'\nimport { MinimalEntityBulkShareResult } from '../../icc-api/model/requests/MinimalEntityBulkShareResult'\nimport { EncryptedFieldsManifest } from '../utils'\nimport { BulkShareOrUpdateMetadataParams } from '../../icc-api/model/requests/BulkShareOrUpdateMetadataParams'\n\n/**\n * @internal this interface is meant only for internal use and may be changed without notice.\n * Gives access to several functions to access encrypted entities metadata.\n */\nexport interface ExtendedApisUtils {\n // region metadata decryption\n /**\n * Get the encryption keys of an entity that the provided data owner can access, potentially using the keys for his parent.\n * There should only be one encryption key for each entity, but the method supports more to allow to deal with conflicts and merged duplicate data.\n * @param entity an encrypted entity.\n * @param dataOwnerId optionally a data owner part of the hierarchy for the current data owner, defaults to the current data owner.\n * @return the encryption keys that the provided data owner can decrypt, deduplicated.\n */\n encryptionKeysOf(entity: EncryptedEntityWithType, dataOwnerId: string | undefined): Promise<string[]>\n\n /**\n * Get the encryption keys of an entity that the current data owner and his parents can access. The resulting array contains the keys for each data\n * owner in the hierarchy which can be decrypted using only that data owner keys (excludes keys accessible through the parent keys). The order of\n * the array is the same as in {@link IccDataOwnerXApi.getCurrentDataOwnerHierarchyIds}.\n * Note that different data owners may have access to the same keys, but the keys extracted for each data owner are deduplicated.\n * There should only be one encryption key for each entity, but the method supports more to allow to deal with conflicts and merged duplicate data.\n * @param entity an encrypted entity.\n * @return the encryption keys that each member of the current data owner hierarchy can decrypt using only his keys and not keys of his parents.\n */\n encryptionKeysForHcpHierarchyOf(entity: EncryptedEntityWithType): Promise<{ ownerId: string; extracted: string[] }[]>\n\n /**\n * Get the secret ids (SFKs) of an entity that the provided data owner can access, potentially using the keys for his parent.\n * @param entity an encrypted entity.\n * @param dataOwnerId optionally a data owner part of the hierarchy for the current data owner, defaults to the current data owner.\n * @return the secret ids (SFKs) that the provided data owner can decrypt, deduplicated.\n */\n secretIdsOf(entity: EncryptedEntityWithType, dataOwnerId: string | undefined): Promise<string[]>\n\n /**\n * Get the secret ids (SFKs) of an entity that the current data owner and his parents can access. The resulting array contains the ids for each data\n * owner in the hierarchy which can be decrypted using only that data owner keys (excludes ids accessible through the parent keys). The order of\n * the array is the same as in {@link IccDataOwnerXApi.getCurrentDataOwnerHierarchyIds}.\n * Note that different data owners may have access to the same secret ids, but the secret ids extracted for each data owner are deduplicated.\n * @param entity an encrypted entity.\n * @return the secret ids that each member of the current data owner hierarchy can decrypt using only his keys and not keys of his parents.\n */\n secretIdsForHcpHierarchyOf(entity: EncryptedEntityWithType): Promise<{ ownerId: string; extracted: string[] }[]>\n\n /**\n * Get the decrypted owning entity ids (formerly CFKs) for the provided entity that can be decrypted using the private keys of the current data\n * owner and his parents. The owning entity id would be, for example, the id of a patient for contact and healthcare elements, or the id of a\n * message for documents.\n * There should only be one owning entity id for each entity, but the method supports more to allow to deal with conflicts and merged duplicate\n * data.\n * @param entity an encrypted entity.\n * @param dataOwnerId optionally a data owner part of the hierarchy for the current data owner, defaults to the current data owner.\n * @return the owning entity ids (CFKs) that the provided data owner can decrypt, deduplicated.\n */\n owningEntityIdsOf(entity: EncryptedEntityWithType, dataOwnerId: string | undefined): Promise<string[]>\n\n /**\n * Get the decrypted owning entity ids (formerly CFKs) for the provided entity that can be decrypted using the private keys of the current data\n * owner and his parents. The owning entity id would be, for example, the id of a patient for contact and healthcare elements, or the id of a\n * message for documents.\n * The resulting array contains the ids for each data owner in the hierarchy which can be decrypted using only that data owner keys (excludes ids\n * accessible through the parent keys). The order of the array is the same as in {@link IccDataOwnerXApi.getCurrentDataOwnerHierarchyIds}.\n * Note that different data owners may have access to the same owning entity ids, but the owning entity ids extracted for each data owner are\n * deduplicated in case they could be accessed through different delegations.\n * There should only be one owning entity id for each entity, but the method supports more to allow to deal with conflicts and merged duplicate\n * data.\n * @param entity an encrypted entity.\n * @return the owning entity ids that each member of the current data owner hierarchy can decrypt using only his keys and not keys of his parents.\n */\n owningEntityIdsForHcpHierarchyOf(entity: EncryptedEntityWithType): Promise<{ ownerId: string; extracted: string[] }[]>\n\n /**\n * Get if the current data owner has write access to the content of the entity.\n * @param entity an entity\n * @return if the current data owner (or one of his parents) has write access to the content of the entity.\n */\n hasWriteAccess(entity: EncryptedEntityWithType): Promise<boolean>\n\n /**\n * @param entity an entity\n * @return if the entity has no encryption metadata and can be safely initialised using .\n */\n hasEmptyEncryptionMetadata(entity: EncryptedEntity): boolean\n // endregion\n\n // region metadata initialisation and share\n /**\n * Initializes encryption metadata for an entity. This includes the encrypted secret id, owning entity id, encryption key for the entity, and\n * the clear text secret foreign key of the parent entity.\n * This method returns a modified copy of the entity and DOES NOT SAVE the entity to the cloud/DB: you will have to save the entity manually.\n * @param entity entity which requires encryption metadata initialisation.\n * @param entityType type of the entity.\n * @param owningEntity id of the owning entity, if any (e.g. patient id for Contact/HealtchareElement, message id for Document, ...).\n * @param owningEntitySecretId secret id of the parent entity, to use in the secret foreign keys for the provided entity, if any.\n * @param initialiseEncryptionKey if false this method will not initialize an encryption key for the entity. Use only for entities which use\n * delegations for access control but don't actually have any encrypted content.\n * HealthcareElement).\n * @param autoDelegations automatically shares the metadata with the provided data owners, with the provided access level.\n * @throws if the entity already has non-empty values for encryption metadata.\n * @return an updated copy of the entity.\n */\n entityWithInitialisedEncryptedMetadata<T extends EncryptedEntity>(\n entity: T,\n entityType: EntityWithDelegationTypeName,\n owningEntity: string | undefined,\n owningEntitySecretId: string | undefined,\n initialiseEncryptionKey: boolean,\n autoDelegations: { [p: string]: SecureDelegation.AccessLevelEnum }\n ): Promise<{ updatedEntity: T; rawEncryptionKey: string | undefined; secretId: string | undefined }>\n\n /**\n * Updates encryption metadata for an entity in order to share it with a delegate or in order to add additional encrypted metadata for an existing\n * delegate.\n * The first time this method is used for a specific delegate it will give access to all unencrypted content of the entity to the delegate data\n * owner. Additionally, this method also allows to share new or existing secret ids (shareSecretId), encryption keys (shareEncryptionKeys) and\n * owning entity ids (shareOwningEntityIds) for the entity.\n * You can use methods like {@link secretIdsOf}, {@link secretIdsForHcpHierarchyOf}, {@link encryptionKeysOf}, ... to retrieve the data you want to\n * share. In most cases you may want to share everything related to the entity, but note that if you use confidential delegations for patients you\n * may want to avoid sharing the confidential secret ids of the current user with other hcps.\n * This updates the entity in the cloud/DB (the updated entities in the returned promise are already saved in the DB). NOTE: this method can only\n * be used with entities which already exist in the cloud (the entities must have been saved).\n * @param entitiesType type of entities to update\n * @param entitiesUpdates share/update requests for each entity. An array of objects containing:\n * - The entity to share/update (or at least its encrypted metadata)\n * - The data to share/update for each delegate. An object associating to each delegate id the data to share/update for that delegate, and the\n * permissions requested for the delegate (ignored if the request will only update already existing shared metadata).\n * @param doRequestBulkShareOrUpdate perform the request to share or update an entity encrypted metadata on the cloud API (and save to DB).\n * @throws if there are duplicate entities in the requested updates.\n * @return a promise which will be completed with an object containing:\n * - the updated entities, only for entities were at least one update was successful\n * - information on the individual requests failed, containing the id of the entity, id of the delegate that the request was for, the content,\n * an error code mirroring an http status code, and a human-friendly description of the error (but not necessarily end-user friendly).\n */\n bulkShareOrUpdateEncryptedEntityMetadata<T extends EncryptedEntityStub>(\n entitiesType: EntityWithDelegationTypeName,\n entitiesUpdates: {\n entity: EncryptedEntityStub\n dataForDelegates: {\n [delegateId: string]: {\n shareSecretIds: string[]\n shareEncryptionKeys: string[]\n shareOwningEntityIds: string[]\n requestedPermissions: RequestedPermissionEnum\n }\n }\n }[],\n doRequestBulkShareOrUpdate: (request: BulkShareOrUpdateMetadataParams) => Promise<EntityBulkShareResult<T>[]>\n ): Promise<{\n updatedEntities: T[]\n unmodifiedEntitiesIds: string[]\n updateErrors: {\n entityId: string\n delegateId: string\n request?: {\n shareSecretIds?: string[]\n shareEncryptionKeys?: string[]\n shareOwningEntityIds?: string[]\n requestedPermissions: RequestedPermissionEnum\n }\n updatedForMigration: boolean\n code?: number\n reason?: string\n }[]\n }>\n\n bulkShareOrUpdateEncryptedEntityMetadataNoEntities(\n entitiesType: EntityWithDelegationTypeName,\n entitiesUpdates: {\n entity: EncryptedEntityStub\n dataForDelegates: {\n [delegateId: string]: {\n shareSecretIds: string[]\n shareEncryptionKeys: string[]\n shareOwningEntityIds: string[]\n requestedPermissions: RequestedPermissionEnum\n }\n }\n }[],\n doRequestBulkShareOrUpdate: (request: BulkShareOrUpdateMetadataParams) => Promise<MinimalEntityBulkShareResult[]>\n ): Promise<{\n unmodifiedEntitiesIds: string[]\n successfulUpdates: { entityId: string; delegateId: string }[]\n updateErrors: {\n entityId: string\n delegateId: string\n request?: {\n shareSecretIds?: string[]\n shareEncryptionKeys?: string[]\n shareOwningEntityIds?: string[]\n requestedPermissions: RequestedPermissionEnum\n }\n updatedForMigration: boolean\n code?: number\n reason?: string\n }[]\n }>\n\n /**\n * Simplified version of {@link bulkShareOrUpdateEncryptedEntityMetadata} for a single entity and with automatic retrieval of the encryption keys\n * and owning entity ids if requested. NOTE: this method can only be used with entities which already exist in the cloud (the entity must have\n * been saved).\n * @param entity an entity.\n * versions. If true the method expects `shareSecretIds` options to always be undefined and will always share any available secret ids. If false\n * it expects `shareSecretIds` options to always be defined and will only share the secret ids specified in the options.\n * @param delegates associates the id of data owners which will be granted access to the entity, to the following sharing options:\n * - shareEncryptionKeys specifies if the encryption keys of the entity should be shared. Defaults to\n * {@link ShareMetadataBehaviour.IF_AVAILABLE}.\n * - shareOwningEntityIds specifies if the owning entity ids of the entity should be shared. Defaults to\n * {@link ShareMetadataBehaviour.IF_AVAILABLE}.\n * - shareSecretIds specifies which secret ids of the entity should be shared. Should be defined only if {@link unusedSecretIds} is false.\n * - requestedPermissions requested permissions for the delegate. Defaults to {@link RequestedPermissionEnum.MAX_WRITE}.\n * @param doRequestBulkShareOrUpdate perform the request to share or update an entity encrypted metadata on the cloud API (and save to DB).\n * @return a promise which will be completed with the result of the operation\n * @throws if shareEncryptionKeys or shareOwningEntityIds is {@link ShareMetadataBehaviour.REQUIRED} and the current data owner can't access any\n * value for the required metadata.\n */\n simpleShareOrUpdateEncryptedEntityMetadata<T extends EncryptedEntityStub>(\n entity: { entity: T; type: EntityWithDelegationTypeName },\n delegates: {\n [p: string]: {\n shareSecretIds: string[] | undefined\n shareEncryptionKeys: ShareMetadataBehaviour | undefined\n shareOwningEntityIds: ShareMetadataBehaviour | undefined\n requestedPermissions: EntityShareRequest.RequestedPermissionEnum | undefined\n }\n },\n doRequestBulkShareOrUpdate: (request: BulkShareOrUpdateMetadataParams) => Promise<EntityBulkShareResult<T>[]>\n ): Promise<ShareResult<T>>\n // endregion\n\n // region content encryption and decryption\n /**\n * Encrypts data using a key of the entity that the provided data owner can access (current data owner by default). If the provided data owner can\n * access multiple encryption keys of the entity there is no guarantee on which key will be used.\n * Note: you should not use this method to encrypt the `encryptedSelf` of iCure entities, since that will be automatically handled by the extended\n * apis. You should use this method only to encrypt additional data, such as document attachments.\n * @param entity an entity.\n * @param type type of the entity.\n * @param content data of the entity which you want to encrypt.\n * @param saveEntity a function which saves the entity to the cloud/DB. Used only if a new encryption key needed to be initialised for the entity.\n * @return the encrypted data and, if a new encryption key was initialised for the entity, the updated entity.\n * @throws if the provided data owner can't access any encryption keys for the entity.\n */\n encryptDataOf<T extends EncryptedEntityStub>(\n entity: T,\n type: EntityWithDelegationTypeName,\n content: ArrayBuffer | Uint8Array,\n saveEntity: (entity: T) => Promise<T>\n ): Promise<{ encryptedData: ArrayBuffer; updatedEntity: T | undefined }>\n\n /**\n * Decrypts data using a key of the entity that the provided data owner can access (current data owner by default). If the provided data owner can\n * access multiple encryption keys each of them will be tried for decryption until one of them gives a result that is valid according to the\n * provided validator.\n * Note: you should not use this method to decrypt the `encryptedSelf` of iCure entities, since that will be automatically handled by the extended\n * apis. You should use this method only to decrypt additional data, such as document attachments.\n * @param entity an entity.\n * @param content data of the entity which you want to decrypt.\n * @param validator a function which verifies the correctness of decrypted content: helps to identify decryption with the wrong key without relying\n * solely on padding.\n * @return the decrypted data.\n * @throws if the provided data owner can't access any encryption keys for the entity, or if no key could be found which provided valid decrypted\n * content according to the validator.\n */\n tryDecryptDataOf(\n entity: EncryptedEntityWithType,\n content: ArrayBuffer | Uint8Array,\n validator: (decryptedData: ArrayBuffer) => Promise<boolean> | undefined\n ): Promise<{ data: ArrayBuffer; wasDecrypted: boolean }>\n\n tryDecryptEntities<T extends EncryptedEntity>(\n entities: T[],\n entityType: EntityWithDelegationTypeName,\n constructor: (json: any) => T\n ): Promise<{ entity: T; decrypted: boolean }[]>\n\n /**\n * Tries to decrypt data to a json object using the provided keys.\n */\n tryDecryptJson(potentialKeys: { key: CryptoKey; raw: string }[], encrypted: Uint8Array, truncateTrailingDecryptedNulls: boolean): Promise<{} | null>\n\n /**\n * Tries to encrypt the content of an encrypted entity.\n * 1. If valid key for encryption is found the method returns the entity with the encrypted fields specified by cryptedKeys\n * 2. If requireEncryption is true and no key could be found for encryption of the entity the method fails.\n * 3. If requireEncryption is false and no key could be found for encryption the method will only check that the entity does not specify any value\n * for fields which should be encrypted according to cryptedKeys (e.g. note in a patient using the default configuration). If the entity specifies\n * a value for any field which should be encrypted the method throws an error, otherwise the method returns the original entity.\n */\n tryEncryptEntities<T extends EncryptedEntity>(\n entities: T[],\n entityType: EntityWithDelegationTypeName,\n fieldsToEncrypt: EncryptedFieldsManifest,\n encodeBinaryData: boolean,\n requireEncryption: boolean,\n constructor: (json: any) => T\n ): Promise<T[]>\n\n /**\n * Verifies if the entity has valid encryption keys (regardless of whether the current data owner has access to them or not). If not this method\n * will throw an error, otherwise it will return undefined. For pre-2018 users there are some cases where the data may have been encrypted with a\n * key not safe for encryption anymore, in which case this method will return the entity with a new and safe encryption key.\n * After this method is called, if it returns an entity it should also be re-encrypted (using the new key) and saved to the cloud.\n */\n ensureEncryptionKeysInitialised<T extends EncryptedEntity>(entity: T, entityType: EntityWithDelegationTypeName): Promise<T | undefined>\n\n /**\n * Attempts to do the action providing \"incrementally decrypted\" keys as input; stops the first time the action\n * completes successfully.\n * The method tries to decrypt encryption keys for the entity \"incrementally\", trying first to decrypt keys that\n * require less effort for decryption (e.g. using already cached exchange data or using exchange data for which the\n * id is known without going through the exchange data map). Each time one or more new keys are decrypted the action\n * is called providing ALL keys decrypted up to that point.\n * If no key can be decrypted at all the method returns null without ever attempting the action (the action always\n * receives at least a key in input or is not called).\n * @param entity the entity from which to decrypt the encryption keys.\n * @param entityType the type of entity\n * @param action the action that consumes the encryption key.\n * @return the wrapped result of the first successful action invocation, or null if the action never succeeded or if\n * no key could be decrypted\n */\n doIncrementallyDecryptingKeys<E extends EncryptedEntity | EncryptedEntityStub, T>(\n entity: E,\n entityType: EntityWithDelegationTypeName,\n action: (entity: E, entityType: EntityWithDelegationTypeName, keys: { key: CryptoKey; raw: string }[]) => Promise<{ success: T } | null>\n ): Promise<{ success: T } | null>\n\n /**\n * Bulk version of {@link doIncrementallyDecryptingKeys}.\n * Differences:\n * - The action is called until it succeeds for all entities or until all decryptable keys have been tried.\n * - For each input the action must return an entry for that entity id with the result if successful or not include\n * the entity id in the result keys if unsuccessful.\n * - An attempt on the action is done only if new keys could be decrypted for all the entities.\n * Additionally, there will be a final attempt after attempting all decryption steps if at least a new key could be\n * decrypted for an entity since the last attempt.\n * In this case entities for which no new key could be decrypted are omitted from the input.\n * @param entities\n * @param entitiesType\n * @param action\n * @return all entities id for which the action completed successfully associated to the result.\n */\n doManyIncrementallyDecryptingKeys<E extends EncryptedEntity | EncryptedEntityStub, T>(\n entities: E[],\n entitiesType: EntityWithDelegationTypeName,\n action: (entity: E, entityType: EntityWithDelegationTypeName, keys: { key: CryptoKey; raw: string }[]) => Promise<{ success: T } | null>\n ): Promise<Map<string, T>>\n // endregion\n}\n"]}
1
+ {"version":3,"file":"ExtendedApisUtils.js","sourceRoot":"","sources":["../../../icc-x-api/crypto/ExtendedApisUtils.ts"],"names":[],"mappings":"","sourcesContent":["import { EncryptedEntity, EncryptedEntityStub } from '../../icc-api/model/models'\nimport { EncryptedEntityWithType, EntityWithDelegationTypeName } from '../utils/EntityWithDelegationTypeName'\nimport { SecureDelegation } from '../../icc-api/model/SecureDelegation'\nimport AccessLevelEnum = SecureDelegation.AccessLevelEnum\nimport { EntityShareOrMetadataUpdateRequest } from '../../icc-api/model/requests/EntityShareOrMetadataUpdateRequest'\nimport { EntityShareRequest } from '../../icc-api/model/requests/EntityShareRequest'\nimport { EntityBulkShareResult } from '../../icc-api/model/requests/EntityBulkShareResult'\nimport RequestedPermissionEnum = EntityShareRequest.RequestedPermissionEnum\nimport { ShareMetadataBehaviour } from './ShareMetadataBehaviour'\nimport { ShareResult } from '../utils/ShareResult'\nimport { MinimalEntityBulkShareResult } from '../../icc-api/model/requests/MinimalEntityBulkShareResult'\nimport { EncryptedFieldsManifest } from '../utils'\nimport { BulkShareOrUpdateMetadataParams } from '../../icc-api/model/requests/BulkShareOrUpdateMetadataParams'\nimport { SecretIdUseOption } from './SecretIdUseOption'\n\n/**\n * @internal this interface is meant only for internal use and may be changed without notice.\n * Gives access to several functions to access encrypted entities metadata.\n */\nexport interface ExtendedApisUtils {\n // region metadata decryption\n /**\n * Get the encryption keys of an entity that the provided data owner can access, potentially using the keys for his parent.\n * There should only be one encryption key for each entity, but the method supports more to allow to deal with conflicts and merged duplicate data.\n * @param entity an encrypted entity.\n * @param dataOwnerId optionally a data owner part of the hierarchy for the current data owner, defaults to the current data owner.\n * @return the encryption keys that the provided data owner can decrypt, deduplicated.\n */\n encryptionKeysOf(entity: EncryptedEntityWithType, dataOwnerId: string | undefined): Promise<string[]>\n\n /**\n * Get the encryption keys of an entity that the current data owner and his parents can access. The resulting array contains the keys for each data\n * owner in the hierarchy which can be decrypted using only that data owner keys (excludes keys accessible through the parent keys). The order of\n * the array is the same as in {@link IccDataOwnerXApi.getCurrentDataOwnerHierarchyIds}.\n * Note that different data owners may have access to the same keys, but the keys extracted for each data owner are deduplicated.\n * There should only be one encryption key for each entity, but the method supports more to allow to deal with conflicts and merged duplicate data.\n * @param entity an encrypted entity.\n * @return the encryption keys that each member of the current data owner hierarchy can decrypt using only his keys and not keys of his parents.\n */\n encryptionKeysForHcpHierarchyOf(entity: EncryptedEntityWithType): Promise<{ ownerId: string; extracted: string[] }[]>\n\n /**\n * Get the secret ids (SFKs) of an entity that the provided data owner can access, potentially using the keys for his parent.\n * @param entity an encrypted entity.\n * @param dataOwnerId optionally a data owner part of the hierarchy for the current data owner, defaults to the current data owner.\n * @return the secret ids (SFKs) that the provided data owner can decrypt, deduplicated.\n */\n secretIdsOf(entity: EncryptedEntityWithType, dataOwnerId: string | undefined): Promise<string[]>\n\n /**\n * Get the secret ids (SFKs) of an entity that the current data owner and his parents can access. The resulting array contains the ids for each data\n * owner in the hierarchy which can be decrypted using only that data owner keys (excludes ids accessible through the parent keys). The order of\n * the array is the same as in {@link IccDataOwnerXApi.getCurrentDataOwnerHierarchyIds}.\n * Note that different data owners may have access to the same secret ids, but the secret ids extracted for each data owner are deduplicated.\n * @param entity an encrypted entity.\n * @return the secret ids that each member of the current data owner hierarchy can decrypt using only his keys and not keys of his parents.\n */\n secretIdsForHcpHierarchyOf(entity: EncryptedEntityWithType): Promise<{ ownerId: string; extracted: string[] }[]>\n\n /**\n * Get the decrypted owning entity ids (formerly CFKs) for the provided entity that can be decrypted using the private keys of the current data\n * owner and his parents. The owning entity id would be, for example, the id of a patient for contact and healthcare elements, or the id of a\n * message for documents.\n * There should only be one owning entity id for each entity, but the method supports more to allow to deal with conflicts and merged duplicate\n * data.\n * @param entity an encrypted entity.\n * @param dataOwnerId optionally a data owner part of the hierarchy for the current data owner, defaults to the current data owner.\n * @return the owning entity ids (CFKs) that the provided data owner can decrypt, deduplicated.\n */\n owningEntityIdsOf(entity: EncryptedEntityWithType, dataOwnerId: string | undefined): Promise<string[]>\n\n /**\n * Get the decrypted owning entity ids (formerly CFKs) for the provided entity that can be decrypted using the private keys of the current data\n * owner and his parents. The owning entity id would be, for example, the id of a patient for contact and healthcare elements, or the id of a\n * message for documents.\n * The resulting array contains the ids for each data owner in the hierarchy which can be decrypted using only that data owner keys (excludes ids\n * accessible through the parent keys). The order of the array is the same as in {@link IccDataOwnerXApi.getCurrentDataOwnerHierarchyIds}.\n * Note that different data owners may have access to the same owning entity ids, but the owning entity ids extracted for each data owner are\n * deduplicated in case they could be accessed through different delegations.\n * There should only be one owning entity id for each entity, but the method supports more to allow to deal with conflicts and merged duplicate\n * data.\n * @param entity an encrypted entity.\n * @return the owning entity ids that each member of the current data owner hierarchy can decrypt using only his keys and not keys of his parents.\n */\n owningEntityIdsForHcpHierarchyOf(entity: EncryptedEntityWithType): Promise<{ ownerId: string; extracted: string[] }[]>\n\n /**\n * Get if the current data owner has write access to the content of the entity.\n * @param entity an entity\n * @return if the current data owner (or one of his parents) has write access to the content of the entity.\n */\n hasWriteAccess(entity: EncryptedEntityWithType): Promise<boolean>\n\n /**\n * @param entity an entity\n * @return if the entity has no encryption metadata and can be safely initialised using .\n */\n hasEmptyEncryptionMetadata(entity: EncryptedEntity): boolean\n // endregion\n\n // region metadata initialisation and share\n resolveSecretIdUseOptions(entity: EncryptedEntityWithType, option: SecretIdUseOption): Promise<string[]>\n\n /**\n * Initializes encryption metadata for an entity. This includes the encrypted secret id, owning entity id, encryption key for the entity, and\n * the clear text secret foreign key of the parent entity.\n * This method returns a modified copy of the entity and DOES NOT SAVE the entity to the cloud/DB: you will have to save the entity manually.\n * @param entity entity which requires encryption metadata initialisation.\n * @param entityType type of the entity.\n * @param owningEntity id of the owning entity, if any (e.g. patient id for Contact/HealtchareElement, message id for Document, ...).\n * @param owningEntitySecretIds secret id of the parent entity, to use in the secret foreign keys for the provided entity, if any.\n * @param initialiseEncryptionKey if false this method will not initialize an encryption key for the entity. Use only for entities which use\n * delegations for access control but don't actually have any encrypted content.\n * HealthcareElement).\n * @param autoDelegations automatically shares the metadata with the provided data owners, with the provided access level.\n * @throws if the entity already has non-empty values for encryption metadata.\n * @return an updated copy of the entity.\n */\n entityWithInitialisedEncryptedMetadata<T extends EncryptedEntity>(\n entity: T,\n entityType: EntityWithDelegationTypeName,\n owningEntity: string | undefined,\n owningEntitySecretIds: string[] | undefined,\n initialiseEncryptionKey: boolean,\n autoDelegations: { [p: string]: SecureDelegation.AccessLevelEnum }\n ): Promise<{ updatedEntity: T; rawEncryptionKey: string | undefined; secretId: string | undefined }>\n\n /**\n * Updates encryption metadata for an entity in order to share it with a delegate or in order to add additional encrypted metadata for an existing\n * delegate.\n * The first time this method is used for a specific delegate it will give access to all unencrypted content of the entity to the delegate data\n * owner. Additionally, this method also allows to share new or existing secret ids (shareSecretId), encryption keys (shareEncryptionKeys) and\n * owning entity ids (shareOwningEntityIds) for the entity.\n * You can use methods like {@link secretIdsOf}, {@link secretIdsForHcpHierarchyOf}, {@link encryptionKeysOf}, ... to retrieve the data you want to\n * share. In most cases you may want to share everything related to the entity, but note that if you use confidential delegations for patients you\n * may want to avoid sharing the confidential secret ids of the current user with other hcps.\n * This updates the entity in the cloud/DB (the updated entities in the returned promise are already saved in the DB). NOTE: this method can only\n * be used with entities which already exist in the cloud (the entities must have been saved).\n * @param entitiesType type of entities to update\n * @param entitiesUpdates share/update requests for each entity. An array of objects containing:\n * - The entity to share/update (or at least its encrypted metadata)\n * - The data to share/update for each delegate. An object associating to each delegate id the data to share/update for that delegate, and the\n * permissions requested for the delegate (ignored if the request will only update already existing shared metadata).\n * @param doRequestBulkShareOrUpdate perform the request to share or update an entity encrypted metadata on the cloud API (and save to DB).\n * @throws if there are duplicate entities in the requested updates.\n * @return a promise which will be completed with an object containing:\n * - the updated entities, only for entities were at least one update was successful\n * - information on the individual requests failed, containing the id of the entity, id of the delegate that the request was for, the content,\n * an error code mirroring an http status code, and a human-friendly description of the error (but not necessarily end-user friendly).\n */\n bulkShareOrUpdateEncryptedEntityMetadata<T extends EncryptedEntityStub>(\n entitiesType: EntityWithDelegationTypeName,\n entitiesUpdates: {\n entity: EncryptedEntityStub\n dataForDelegates: {\n [delegateId: string]: {\n shareSecretIds: string[]\n shareEncryptionKeys: string[]\n shareOwningEntityIds: string[]\n requestedPermissions: RequestedPermissionEnum\n }\n }\n }[],\n doRequestBulkShareOrUpdate: (request: BulkShareOrUpdateMetadataParams) => Promise<EntityBulkShareResult<T>[]>\n ): Promise<{\n updatedEntities: T[]\n unmodifiedEntitiesIds: string[]\n updateErrors: {\n entityId: string\n delegateId: string\n request?: {\n shareSecretIds?: string[]\n shareEncryptionKeys?: string[]\n shareOwningEntityIds?: string[]\n requestedPermissions: RequestedPermissionEnum\n }\n updatedForMigration: boolean\n code?: number\n reason?: string\n }[]\n }>\n\n bulkShareOrUpdateEncryptedEntityMetadataNoEntities(\n entitiesType: EntityWithDelegationTypeName,\n entitiesUpdates: {\n entity: EncryptedEntityStub\n dataForDelegates: {\n [delegateId: string]: {\n shareSecretIds: string[]\n shareEncryptionKeys: string[]\n shareOwningEntityIds: string[]\n requestedPermissions: RequestedPermissionEnum\n }\n }\n }[],\n doRequestBulkShareOrUpdate: (request: BulkShareOrUpdateMetadataParams) => Promise<MinimalEntityBulkShareResult[]>\n ): Promise<{\n unmodifiedEntitiesIds: string[]\n successfulUpdates: { entityId: string; delegateId: string }[]\n updateErrors: {\n entityId: string\n delegateId: string\n request?: {\n shareSecretIds?: string[]\n shareEncryptionKeys?: string[]\n shareOwningEntityIds?: string[]\n requestedPermissions: RequestedPermissionEnum\n }\n updatedForMigration: boolean\n code?: number\n reason?: string\n }[]\n }>\n\n /**\n * Simplified version of {@link bulkShareOrUpdateEncryptedEntityMetadata} for a single entity and with automatic retrieval of the encryption keys\n * and owning entity ids if requested. NOTE: this method can only be used with entities which already exist in the cloud (the entity must have\n * been saved).\n * @param entity an entity.\n * versions. If true the method expects `shareSecretIds` options to always be undefined and will always share any available secret ids. If false\n * it expects `shareSecretIds` options to always be defined and will only share the secret ids specified in the options.\n * @param delegates associates the id of data owners which will be granted access to the entity, to the following sharing options:\n * - shareEncryptionKeys specifies if the encryption keys of the entity should be shared. Defaults to\n * {@link ShareMetadataBehaviour.IF_AVAILABLE}.\n * - shareOwningEntityIds specifies if the owning entity ids of the entity should be shared. Defaults to\n * {@link ShareMetadataBehaviour.IF_AVAILABLE}.\n * - shareSecretIds specifies which secret ids of the entity should be shared. Should be defined only if {@link unusedSecretIds} is false.\n * - requestedPermissions requested permissions for the delegate. Defaults to {@link RequestedPermissionEnum.MAX_WRITE}.\n * @param doRequestBulkShareOrUpdate perform the request to share or update an entity encrypted metadata on the cloud API (and save to DB).\n * @return a promise which will be completed with the result of the operation\n * @throws if shareEncryptionKeys or shareOwningEntityIds is {@link ShareMetadataBehaviour.REQUIRED} and the current data owner can't access any\n * value for the required metadata.\n */\n simpleShareOrUpdateEncryptedEntityMetadata<T extends EncryptedEntityStub>(\n entity: { entity: T; type: EntityWithDelegationTypeName },\n delegates: {\n [p: string]: {\n shareSecretIds: string[] | undefined\n shareEncryptionKeys: ShareMetadataBehaviour | undefined\n shareOwningEntityIds: ShareMetadataBehaviour | undefined\n requestedPermissions: EntityShareRequest.RequestedPermissionEnum | undefined\n }\n },\n doRequestBulkShareOrUpdate: (request: BulkShareOrUpdateMetadataParams) => Promise<EntityBulkShareResult<T>[]>\n ): Promise<ShareResult<T>>\n // endregion\n\n // region content encryption and decryption\n /**\n * Encrypts data using a key of the entity that the provided data owner can access (current data owner by default). If the provided data owner can\n * access multiple encryption keys of the entity there is no guarantee on which key will be used.\n * Note: you should not use this method to encrypt the `encryptedSelf` of iCure entities, since that will be automatically handled by the extended\n * apis. You should use this method only to encrypt additional data, such as document attachments.\n * @param entity an entity.\n * @param type type of the entity.\n * @param content data of the entity which you want to encrypt.\n * @param saveEntity a function which saves the entity to the cloud/DB. Used only if a new encryption key needed to be initialised for the entity.\n * @return the encrypted data and, if a new encryption key was initialised for the entity, the updated entity.\n * @throws if the provided data owner can't access any encryption keys for the entity.\n */\n encryptDataOf<T extends EncryptedEntityStub>(\n entity: T,\n type: EntityWithDelegationTypeName,\n content: ArrayBuffer | Uint8Array,\n saveEntity: (entity: T) => Promise<T>\n ): Promise<{ encryptedData: ArrayBuffer; updatedEntity: T | undefined }>\n\n /**\n * Decrypts data using a key of the entity that the provided data owner can access (current data owner by default). If the provided data owner can\n * access multiple encryption keys each of them will be tried for decryption until one of them gives a result that is valid according to the\n * provided validator.\n * Note: you should not use this method to decrypt the `encryptedSelf` of iCure entities, since that will be automatically handled by the extended\n * apis. You should use this method only to decrypt additional data, such as document attachments.\n * @param entity an entity.\n * @param content data of the entity which you want to decrypt.\n * @param validator a function which verifies the correctness of decrypted content: helps to identify decryption with the wrong key without relying\n * solely on padding.\n * @return the decrypted data.\n * @throws if the provided data owner can't access any encryption keys for the entity, or if no key could be found which provided valid decrypted\n * content according to the validator.\n */\n tryDecryptDataOf(\n entity: EncryptedEntityWithType,\n content: ArrayBuffer | Uint8Array,\n validator: (decryptedData: ArrayBuffer) => Promise<boolean> | undefined\n ): Promise<{ data: ArrayBuffer; wasDecrypted: boolean }>\n\n tryDecryptEntities<T extends EncryptedEntity>(\n entities: T[],\n entityType: EntityWithDelegationTypeName,\n constructor: (json: any) => T\n ): Promise<{ entity: T; decrypted: boolean }[]>\n\n /**\n * Tries to decrypt data to a json object using the provided keys.\n */\n tryDecryptJson(potentialKeys: { key: CryptoKey; raw: string }[], encrypted: Uint8Array, truncateTrailingDecryptedNulls: boolean): Promise<{} | null>\n\n /**\n * Tries to encrypt the content of an encrypted entity.\n * 1. If valid key for encryption is found the method returns the entity with the encrypted fields specified by cryptedKeys\n * 2. If requireEncryption is true and no key could be found for encryption of the entity the method fails.\n * 3. If requireEncryption is false and no key could be found for encryption the method will only check that the entity does not specify any value\n * for fields which should be encrypted according to cryptedKeys (e.g. note in a patient using the default configuration). If the entity specifies\n * a value for any field which should be encrypted the method throws an error, otherwise the method returns the original entity.\n */\n tryEncryptEntities<T extends EncryptedEntity>(\n entities: T[],\n entityType: EntityWithDelegationTypeName,\n fieldsToEncrypt: EncryptedFieldsManifest,\n encodeBinaryData: boolean,\n requireEncryption: boolean,\n constructor: (json: any) => T\n ): Promise<T[]>\n\n /**\n * Verifies if the entity has valid encryption keys (regardless of whether the current data owner has access to them or not). If not this method\n * will throw an error, otherwise it will return undefined. For pre-2018 users there are some cases where the data may have been encrypted with a\n * key not safe for encryption anymore, in which case this method will return the entity with a new and safe encryption key.\n * After this method is called, if it returns an entity it should also be re-encrypted (using the new key) and saved to the cloud.\n */\n ensureEncryptionKeysInitialised<T extends EncryptedEntity>(entity: T, entityType: EntityWithDelegationTypeName): Promise<T | undefined>\n\n /**\n * Attempts to do the action providing \"incrementally decrypted\" keys as input; stops the first time the action\n * completes successfully.\n * The method tries to decrypt encryption keys for the entity \"incrementally\", trying first to decrypt keys that\n * require less effort for decryption (e.g. using already cached exchange data or using exchange data for which the\n * id is known without going through the exchange data map). Each time one or more new keys are decrypted the action\n * is called providing ALL keys decrypted up to that point.\n * If no key can be decrypted at all the method returns null without ever attempting the action (the action always\n * receives at least a key in input or is not called).\n * @param entity the entity from which to decrypt the encryption keys.\n * @param entityType the type of entity\n * @param action the action that consumes the encryption key.\n * @return the wrapped result of the first successful action invocation, or null if the action never succeeded or if\n * no key could be decrypted\n */\n doIncrementallyDecryptingKeys<E extends EncryptedEntity | EncryptedEntityStub, T>(\n entity: E,\n entityType: EntityWithDelegationTypeName,\n action: (entity: E, entityType: EntityWithDelegationTypeName, keys: { key: CryptoKey; raw: string }[]) => Promise<{ success: T } | null>\n ): Promise<{ success: T } | null>\n\n /**\n * Bulk version of {@link doIncrementallyDecryptingKeys}.\n * Differences:\n * - The action is called until it succeeds for all entities or until all decryptable keys have been tried.\n * - For each input the action must return an entry for that entity id with the result if successful or not include\n * the entity id in the result keys if unsuccessful.\n * - An attempt on the action is done only if new keys could be decrypted for all the entities.\n * Additionally, there will be a final attempt after attempting all decryption steps if at least a new key could be\n * decrypted for an entity since the last attempt.\n * In this case entities for which no new key could be decrypted are omitted from the input.\n * @param entities\n * @param entitiesType\n * @param action\n * @return all entities id for which the action completed successfully associated to the result.\n */\n doManyIncrementallyDecryptingKeys<E extends EncryptedEntity | EncryptedEntityStub, T>(\n entities: E[],\n entitiesType: EntityWithDelegationTypeName,\n action: (entity: E, entityType: EntityWithDelegationTypeName, keys: { key: CryptoKey; raw: string }[]) => Promise<{ success: T } | null>\n ): Promise<Map<string, T>>\n // endregion\n\n // region confidential ids\n\n /**\n * Ensures that the current data owner has access to a confidential secret id for the provided entity: this is an id that is known to the data owner\n * but is not known by any of his parents. If there is currently no confidential secret id for this entity the method returns a copy of the entity\n * with a new confidential secret id for the current data owner (the entity in the database won't be updated), else this method returns undefined.\n * New confidential secret ids will have an appropriate tag, but existing confidential secret ids may not necessarily have it.\n * @param entity an entity which needs to have a confidential secret id for the current data owner\n * @param entityType the type of the entity\n * @param doRequestBulkShareOrUpdate perform the request to share or update an entity encrypted metadata on the cloud API (and save to DB).\n * @return undefined if the entity already had a confidential secret id for the current user, or the updated AND SAVED entity with the new\n * confidential secret id.\n */\n initialiseConfidentialSecretId<T extends EncryptedEntity>(\n entity: T,\n entityType: EntityWithDelegationTypeName,\n doRequestBulkShareOrUpdate: (request: BulkShareOrUpdateMetadataParams) => Promise<EntityBulkShareResult<T>[]>\n ): Promise<T | undefined>\n\n /**\n * Get an existing confidential secret id of the provided entity for the provided data owner (current data owner by default). A confidential secret\n * id is a secret id known by the data owner but not known by any of his parents: note however that children will know confidential secret ids.\n * @param entity an entity for which you want to retrieve the confidential secret id.\n * @param dataOwnerId (current data owner by default) a data owner for which you want to get a confidential secret id.\n * @return the confidential secret id or undefined if there is no confidential secret id for the provided data owner.\n */\n getConfidentialSecretId(entity: EncryptedEntityWithType, dataOwnerId?: string): Promise<string | undefined>\n\n /**\n * Get all existing confidential secret ids of the provided entity for the provided data owner (current data owner by default). A confidential secret\n * id is a secret id known by the data owner but not known by any of his parents: note however that children will know confidential secret ids.\n * @param entity an entity for which you want to retrieve the confidential secret id.\n * @param dataOwnerId (current data owner by default) a data owner for which you want to get a confidential secret id.\n * @return the confidential secret ids for the data owner (may be empty).\n */\n getConfidentialSecretIds(entity: EncryptedEntityWithType, dataOwnerId?: string): Promise<string[]>\n\n /**\n * Gets a secret id known by the topmost parent of the current data owner hierarchy. If there is multiple secret ids shared with the topmost parent\n * there is no guarantee on which one will be chosen.\n * @param entity an entity.\n * @return a secret id known by the topmost parent of the current data owner hierarchy, or undefined if there is no secret id currently available\n * for the topmost parent.\n */\n getAnySecretIdSharedWithParents(entity: EncryptedEntityWithType): Promise<string | undefined>\n\n /**\n * Gets all secret ids known by the topmost parent of the current data owner hierarchy (or all secret ids known by the current data owner if he is\n * not part of any data owner hierarchy).\n * @param entity an entity.\n * @return all secret ids known by the topmost parent of the current data owner hierarchy, may be empty.\n */\n getSecretIdsSharedWithParents(entity: EncryptedEntityWithType): Promise<string[]>\n // endregion\n}\n"]}
@@ -14,6 +14,7 @@ import { IccUserXApi } from '../icc-user-x-api';
14
14
  import { MinimalEntityBulkShareResult } from '../../icc-api/model/requests/MinimalEntityBulkShareResult';
15
15
  import { BulkShareOrUpdateMetadataParams } from '../../icc-api/model/requests/BulkShareOrUpdateMetadataParams';
16
16
  import RequestedPermissionEnum = EntityShareRequest.RequestedPermissionEnum;
17
+ import { SecretIdUseOption } from './SecretIdUseOption';
17
18
  /**
18
19
  * @internal this class is for internal use only and may be changed without notice.
19
20
  * Methods to support extended apis.
@@ -42,7 +43,7 @@ export declare class ExtendedApisUtilsImpl implements ExtendedApisUtils {
42
43
  extracted: string[];
43
44
  }[]>;
44
45
  hasWriteAccess(entity: EncryptedEntityWithType): Promise<boolean>;
45
- entityWithInitialisedEncryptedMetadata<T extends EncryptedEntity>(entity: T, entityType: EntityWithDelegationTypeName, owningEntity: string | undefined, owningEntitySecretId: string | undefined, initialiseEncryptionKey: boolean, autoDelegations: {
46
+ entityWithInitialisedEncryptedMetadata<T extends EncryptedEntity>(entity: T, entityType: EntityWithDelegationTypeName, owningEntity: string | undefined, owningEntitySecretIds: string[] | undefined, initialiseEncryptionKey: boolean, autoDelegations: {
46
47
  [p: string]: SecureDelegation.AccessLevelEnum;
47
48
  }): Promise<{
48
49
  updatedEntity: T;
@@ -160,4 +161,10 @@ export declare class ExtendedApisUtilsImpl implements ExtendedApisUtils {
160
161
  private checkEmptyEncryptionMetadata;
161
162
  hasEmptyEncryptionMetadata(entity: EncryptedEntity): boolean;
162
163
  private doCheckEmptyEncryptionMetadata;
164
+ initialiseConfidentialSecretId<T extends EncryptedEntity>(entity: T, entityType: EntityWithDelegationTypeName, doRequestBulkShareOrUpdate: (request: BulkShareOrUpdateMetadataParams) => Promise<EntityBulkShareResult<T>[]>): Promise<T | undefined>;
165
+ getConfidentialSecretId(entity: EncryptedEntityWithType, dataOwnerId?: string): Promise<string | undefined>;
166
+ getConfidentialSecretIds(entity: EncryptedEntityWithType, dataOwnerId?: string): Promise<string[]>;
167
+ getAnySecretIdSharedWithParents(entity: EncryptedEntityWithType): Promise<string | undefined>;
168
+ getSecretIdsSharedWithParents(entity: EncryptedEntityWithType): Promise<string[]>;
169
+ resolveSecretIdUseOptions(entity: EncryptedEntityWithType, option: SecretIdUseOption): Promise<string[]>;
163
170
  }
@@ -20,6 +20,7 @@ var AccessLevel = SecureDelegation_1.SecureDelegation.AccessLevelEnum;
20
20
  var RequestedPermissionEnum = EntityShareRequest_1.EntityShareRequest.RequestedPermissionEnum;
21
21
  var RequestedPermissionInternal = EntityShareRequest_1.EntityShareRequest.RequestedPermissionInternal;
22
22
  var AccessLevelEnum = SecureDelegation_1.SecureDelegation.AccessLevelEnum;
23
+ const SecretIdUseOption_1 = require("./SecretIdUseOption");
23
24
  /**
24
25
  * @internal this class is for internal use only and may be changed without notice.
25
26
  * Methods to support extended apis.
@@ -69,14 +70,14 @@ class ExtendedApisUtilsImpl {
69
70
  AccessLevel.WRITE);
70
71
  });
71
72
  }
72
- entityWithInitialisedEncryptedMetadata(entity, entityType, owningEntity, owningEntitySecretId, initialiseEncryptionKey, autoDelegations) {
73
+ entityWithInitialisedEncryptedMetadata(entity, entityType, owningEntity, owningEntitySecretIds, initialiseEncryptionKey, autoDelegations) {
73
74
  return __awaiter(this, arguments, void 0, function* () {
74
75
  this.throwDetailedExceptionForInvalidParameter('entity.id', entity.id, 'entityWithInitialisedEncryptedMetadata', arguments);
75
76
  this.checkEmptyEncryptionMetadata(entity);
76
77
  const newRawKey = initialiseEncryptionKey ? yield this.primitives.AES.generateCryptoKey(true) : undefined;
77
78
  const newSecretId = this.primitives.randomUuid();
78
79
  return {
79
- updatedEntity: yield this.secureDelegationsManager.entityWithInitialisedEncryptedMetadata(Object.assign(Object.assign({}, entity), { secretForeignKeys: owningEntitySecretId ? [owningEntitySecretId] : [] }), entityType, newSecretId ? [newSecretId] : [], !!owningEntity ? [owningEntity] : [], newRawKey ? [newRawKey] : [], autoDelegations),
80
+ updatedEntity: yield this.secureDelegationsManager.entityWithInitialisedEncryptedMetadata(Object.assign(Object.assign({}, entity), { secretForeignKeys: owningEntitySecretIds !== null && owningEntitySecretIds !== void 0 ? owningEntitySecretIds : [] }), entityType, newSecretId ? [newSecretId] : [], !!owningEntity ? [owningEntity] : [], newRawKey ? [newRawKey] : [], autoDelegations),
80
81
  rawEncryptionKey: newRawKey,
81
82
  secretId: newSecretId,
82
83
  };
@@ -644,6 +645,84 @@ class ExtendedApisUtilsImpl {
644
645
  }
645
646
  return true;
646
647
  }
648
+ initialiseConfidentialSecretId(entity, entityType, doRequestBulkShareOrUpdate) {
649
+ return __awaiter(this, void 0, void 0, function* () {
650
+ if (yield this.getConfidentialSecretId({ entity, type: entityType }))
651
+ return undefined;
652
+ const confidentialSecretId = this.primitives.randomUuid();
653
+ return (yield this.simpleShareOrUpdateEncryptedEntityMetadata({ entity, type: entityType }, {
654
+ [yield this.dataOwnerApi.getCurrentDataOwnerId()]: {
655
+ shareEncryptionKeys: ShareMetadataBehaviour_1.ShareMetadataBehaviour.NEVER,
656
+ shareOwningEntityIds: ShareMetadataBehaviour_1.ShareMetadataBehaviour.NEVER,
657
+ shareSecretIds: [confidentialSecretId],
658
+ requestedPermissions: RequestedPermissionEnum.MAX_WRITE,
659
+ },
660
+ }, (request) => doRequestBulkShareOrUpdate(request))).updatedEntityOrThrow;
661
+ });
662
+ }
663
+ getConfidentialSecretId(entity, dataOwnerId) {
664
+ return __awaiter(this, void 0, void 0, function* () {
665
+ return this.getConfidentialSecretIds(entity, dataOwnerId).then((x) => x[0]);
666
+ });
667
+ }
668
+ getConfidentialSecretIds(entity, dataOwnerId) {
669
+ return __awaiter(this, void 0, void 0, function* () {
670
+ const chosenDataOwnerId = dataOwnerId !== null && dataOwnerId !== void 0 ? dataOwnerId : (yield this.dataOwnerApi.getCurrentDataOwnerId());
671
+ const dataOwnerHierarchy = yield this.dataOwnerApi.getCurrentDataOwnerHierarchyIdsFrom(chosenDataOwnerId);
672
+ const hierarchySecretIds = (yield this.secretIdsForHcpHierarchyOf(entity)).filter((x) => dataOwnerHierarchy.includes(x.ownerId));
673
+ const keysForDataOwner = hierarchySecretIds.find((x) => x.ownerId === chosenDataOwnerId);
674
+ if (!keysForDataOwner)
675
+ return [];
676
+ return keysForDataOwner.extracted.filter((k) => !hierarchySecretIds.some((x) => x.ownerId !== chosenDataOwnerId && x.extracted.includes(k)));
677
+ });
678
+ }
679
+ getAnySecretIdSharedWithParents(entity) {
680
+ return __awaiter(this, void 0, void 0, function* () {
681
+ return (yield this.getSecretIdsSharedWithParents(entity))[0];
682
+ });
683
+ }
684
+ getSecretIdsSharedWithParents(entity) {
685
+ return __awaiter(this, void 0, void 0, function* () {
686
+ return (yield this.secretIdsForHcpHierarchyOf(entity))[0].extracted;
687
+ });
688
+ }
689
+ resolveSecretIdUseOptions(entity, option) {
690
+ return __awaiter(this, void 0, void 0, function* () {
691
+ if (option == SecretIdUseOption_1.SecretIdUseOption.UseNone) {
692
+ return [];
693
+ }
694
+ else if (option == SecretIdUseOption_1.SecretIdUseOption.UseAnyConfidential) {
695
+ const all = yield this.getConfidentialSecretIds(entity, undefined);
696
+ if (all.length == 0)
697
+ throw new Error("Couldn't find any confidential secret id");
698
+ return [all[0]];
699
+ }
700
+ else if (option == SecretIdUseOption_1.SecretIdUseOption.UseAllConfidential) {
701
+ const all = yield this.getConfidentialSecretIds(entity, undefined);
702
+ if (all.length == 0)
703
+ throw new Error("Couldn't find any confidential secret id");
704
+ return all;
705
+ }
706
+ else if (option == SecretIdUseOption_1.SecretIdUseOption.UseAnySharedWithParent) {
707
+ const all = yield this.getSecretIdsSharedWithParents(entity);
708
+ if (all.length == 0)
709
+ throw new Error("Couldn't find any secret id shared with parent");
710
+ return [all[0]];
711
+ }
712
+ else if (option == SecretIdUseOption_1.SecretIdUseOption.UseAllSharedWithParent) {
713
+ const all = yield this.getSecretIdsSharedWithParents(entity);
714
+ if (all.length == 0)
715
+ throw new Error("Couldn't find any secret id shared with parent");
716
+ return all;
717
+ }
718
+ else if (option instanceof SecretIdUseOption_1.SecretIdUseOption.Use) {
719
+ return [...new Set(option.secretIds)];
720
+ }
721
+ else {
722
+ throw new Error(`Unrecognized SecretIdUseOption ${option}`);
723
+ }
724
+ });
725
+ }
647
726
  }
648
727
  exports.ExtendedApisUtilsImpl = ExtendedApisUtilsImpl;
649
728
  //# sourceMappingURL=ExtendedApisUtilsImpl.js.map