@icure/api 7.0.0-beta.4 → 7.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/icc-api/api/IccDocumentApi.d.ts +6 -4
- package/icc-api/api/IccDocumentApi.js +8 -5
- package/icc-api/api/IccDocumentApi.js.map +1 -1
- package/icc-api/model/Address.d.ts +6 -0
- package/icc-api/model/Address.js.map +1 -1
- package/icc-api/model/Annotation.d.ts +18 -0
- package/icc-api/model/Annotation.js.map +1 -1
- package/icc-api/model/Connection.d.ts +16 -0
- package/icc-api/model/Connection.js +38 -0
- package/icc-api/model/Connection.js.map +1 -0
- package/icc-api/model/Content.js +1 -1
- package/icc-api/model/Content.js.map +1 -1
- package/icc-api/model/CryptoActorStub.d.ts +5 -0
- package/icc-api/model/CryptoActorStub.js +1 -0
- package/icc-api/model/CryptoActorStub.js.map +1 -1
- package/icc-api/model/Delegation.d.ts +3 -0
- package/icc-api/model/Delegation.js.map +1 -1
- package/icc-api/model/HealthElement.d.ts +6 -0
- package/icc-api/model/HealthElement.js.map +1 -1
- package/icc-api/model/HealthcareParty.js +1 -1
- package/icc-api/model/HealthcareParty.js.map +1 -1
- package/icc-api/model/ISO639_1.d.ts +8 -0
- package/icc-api/model/ISO639_1.js +3 -0
- package/icc-api/model/ISO639_1.js.map +1 -0
- package/icc-api/model/Patient.d.ts +7 -0
- package/icc-api/model/Patient.js +1 -1
- package/icc-api/model/Patient.js.map +1 -1
- package/icc-api/model/models.d.ts +2 -0
- package/icc-api/model/models.js +1 -0
- package/icc-api/model/models.js.map +1 -1
- package/icc-x-api/crypto/EntitiesEncryption.d.ts +2 -1
- package/icc-x-api/crypto/EntitiesEncryption.js +13 -11
- package/icc-x-api/crypto/EntitiesEncryption.js.map +1 -1
- package/icc-x-api/filters/filters.d.ts +4 -0
- package/icc-x-api/filters/filters.js +4 -0
- package/icc-x-api/filters/filters.js.map +1 -1
- package/icc-x-api/icc-accesslog-x-api.d.ts +1 -1
- package/icc-x-api/icc-accesslog-x-api.js +9 -21
- package/icc-x-api/icc-accesslog-x-api.js.map +1 -1
- package/icc-x-api/icc-calendar-item-x-api.d.ts +1 -1
- package/icc-x-api/icc-calendar-item-x-api.js +9 -18
- package/icc-x-api/icc-calendar-item-x-api.js.map +1 -1
- package/icc-x-api/icc-classification-x-api.js +6 -17
- package/icc-x-api/icc-classification-x-api.js.map +1 -1
- package/icc-x-api/icc-contact-x-api.d.ts +30 -2
- package/icc-x-api/icc-contact-x-api.js +82 -96
- package/icc-x-api/icc-contact-x-api.js.map +1 -1
- package/icc-x-api/icc-device-x-api.d.ts +17 -0
- package/icc-x-api/icc-device-x-api.js +35 -0
- package/icc-x-api/icc-device-x-api.js.map +1 -0
- package/icc-x-api/icc-doctemplate-x-api.js +2 -13
- package/icc-x-api/icc-doctemplate-x-api.js.map +1 -1
- package/icc-x-api/icc-document-x-api.d.ts +12 -4
- package/icc-x-api/icc-document-x-api.js +22 -23
- package/icc-x-api/icc-document-x-api.js.map +1 -1
- package/icc-x-api/icc-form-x-api.js +6 -15
- package/icc-x-api/icc-form-x-api.js.map +1 -1
- package/icc-x-api/icc-hcparty-x-api.d.ts +9 -2
- package/icc-x-api/icc-hcparty-x-api.js +9 -1
- package/icc-x-api/icc-hcparty-x-api.js.map +1 -1
- package/icc-x-api/icc-helement-x-api.d.ts +12 -3
- package/icc-x-api/icc-helement-x-api.js +19 -19
- package/icc-x-api/icc-helement-x-api.js.map +1 -1
- package/icc-x-api/icc-invoice-x-api.js +6 -17
- package/icc-x-api/icc-invoice-x-api.js.map +1 -1
- package/icc-x-api/icc-maintenance-task-x-api.d.ts +12 -2
- package/icc-x-api/icc-maintenance-task-x-api.js +17 -13
- package/icc-x-api/icc-maintenance-task-x-api.js.map +1 -1
- package/icc-x-api/icc-message-x-api.js +6 -16
- package/icc-x-api/icc-message-x-api.js.map +1 -1
- package/icc-x-api/icc-patient-x-api.d.ts +12 -3
- package/icc-x-api/icc-patient-x-api.js +21 -18
- package/icc-x-api/icc-patient-x-api.js.map +1 -1
- package/icc-x-api/icc-receipt-x-api.js +5 -15
- package/icc-x-api/icc-receipt-x-api.js.map +1 -1
- package/icc-x-api/icc-time-table-x-api.js +5 -15
- package/icc-x-api/icc-time-table-x-api.js.map +1 -1
- package/icc-x-api/icc-user-x-api.d.ts +10 -1
- package/icc-x-api/icc-user-x-api.js +8 -1
- package/icc-x-api/icc-user-x-api.js.map +1 -1
- package/icc-x-api/index.d.ts +110 -4
- package/icc-x-api/index.js +17 -15
- package/icc-x-api/index.js.map +1 -1
- package/icc-x-api/utils/crypto-utils.d.ts +140 -11
- package/icc-x-api/utils/crypto-utils.js +285 -36
- package/icc-x-api/utils/crypto-utils.js.map +1 -1
- package/icc-x-api/utils/index.d.ts +1 -0
- package/icc-x-api/utils/index.js +1 -0
- package/icc-x-api/utils/index.js.map +1 -1
- package/icc-x-api/utils/websocket.d.ts +61 -0
- package/icc-x-api/utils/websocket.js +351 -0
- package/icc-x-api/utils/websocket.js.map +1 -0
- package/package.json +5 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icc-receipt-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-receipt-x-api.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wCAA0C;AAE1C,4BAA2B;AAC3B,kDAAiD;AAEjD,0EAAgG;AAIhG,MAAa,cAAe,SAAQ,uBAAa;IAG/C,YACE,IAAY,EACZ,OAAkC,EAC1B,MAAqB,EAC7B,YAA8B,EAC9B,yBAAiD,IAAI,iDAAwB,EAAE,EAC/E,YAA2E,OAAO,MAAM,KAAK,WAAW;QACtG,CAAC,CAAC,MAAM,CAAC,KAAK;QACd,CAAC,CAAC,OAAO,IAAI,KAAK,WAAW;YAC7B,CAAC,CAAC,IAAI,CAAC,KAAK;YACZ,CAAC,CAAC,KAAK;QAET,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,sBAAsB,EAAE,SAAS,CAAC,CAAA;QAT/C,WAAM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,MAAsB;;YAIpD,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,yBAAyB,CAAC,MAAM,CAAC,CAAA;QACrE,CAAC;KAAA;IAEK,mBAAmB,CAAC,MAAsB;;YAC9C,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAA;QAC5D,CAAC;KAAA;CACF;AA9LD,wCA8LC","sourcesContent":["import { IccReceiptApi } from '../icc-api'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\nimport * as _ from 'lodash'\nimport * as models from '../icc-api/model/models'\nimport { IccDataOwnerXApi } from './icc-data-owner-x-api'\nimport { AuthenticationProvider, NoAuthenticationProvider } from './auth/AuthenticationProvider'\nimport { ShareMetadataBehaviour } from './crypto/ShareMetadataBehaviour'\nimport { EncryptedEntityXApi } from './basexapi/EncryptedEntityXApi'\n\nexport class IccReceiptXApi extends IccReceiptApi implements EncryptedEntityXApi<models.Receipt> {\n dataOwnerApi: IccDataOwnerXApi\n\n constructor(\n host: string,\n headers: { [key: string]: string },\n private crypto: IccCryptoXApi,\n dataOwnerApi: IccDataOwnerXApi,\n authenticationProvider: AuthenticationProvider = new NoAuthenticationProvider(),\n fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response> = typeof window !== 'undefined'\n ? window.fetch\n : typeof self !== 'undefined'\n ? self.fetch\n : fetch\n ) {\n super(host, headers, authenticationProvider, fetchImpl)\n this.dataOwnerApi = dataOwnerApi\n }\n\n /**\n * Creates a new instance of receipt with initialised encryption metadata (not in the database).\n * @param user the current user.\n * @param r initialised data for the receipt. Metadata such as id, creation data, etc. will be automatically initialised, but you can specify\n * other kinds of data or overwrite generated metadata with this. You can't specify encryption metadata.\n * @param options optional parameters:\n * - additionalDelegates: delegates which will have access to the entity in addition to the current data owner and delegates from the\n * auto-delegations. Must be an object which associates each data owner id with the access level to give to that data owner. May overlap with\n * auto-delegations, in such case the access level specified here will be used. Currently only WRITE access is supported, but in future also read\n * access will be possible.\n * @return a new instance of receipt.\n */\n async newInstance(\n user: models.User,\n r: any,\n options: {\n additionalDelegates?: { [dataOwnerId: string]: 'WRITE' }\n } = {}\n ): Promise<models.Receipt> {\n const receipt = new models.Receipt(\n _.extend(\n {\n id: this.crypto.randomUuid(),\n _type: 'org.taktik.icure.entities.Receipt',\n created: new Date().getTime(),\n modified: new Date().getTime(),\n responsible: this.dataOwnerApi.getDataOwnerIdOf(user),\n author: user.id,\n codes: [],\n tags: [],\n },\n r || {}\n )\n )\n\n const extraDelegations = [\n ...Object.keys(options.additionalDelegates ?? {}),\n ...(user.autoDelegations?.all ?? []),\n ...(user.autoDelegations?.medicalInformation ?? []),\n ]\n return new models.Receipt(\n await this.crypto.entities\n .entityWithInitialisedEncryptedMetadata(receipt, undefined, undefined, true, extraDelegations)\n .then((x) => x.updatedEntity)\n )\n }\n\n logReceipt(user: models.User, docId: string, refs: Array<string>, blobType: string, blob: ArrayBuffer) {\n return this.newInstance(user, { documentId: docId, references: refs })\n .then((rcpt) => this.createReceipt(rcpt))\n .then((rcpt) => (blob.byteLength != 0 ? this.setReceiptAttachment(rcpt.id!, blobType, '', <any>blob) : Promise.resolve(rcpt)))\n }\n\n /**\n * Adds an attachment to a receipt, encrypting it on client side using the encryption keys of the provided receipt.\n * @param receipt a receipt.\n * @param blobType the type of the attachment.\n * @param attachment a attachment for the receipt.\n * @return the updated receipt.\n */\n async encryptAndSetReceiptAttachment(receipt: models.Receipt, blobType: string, attachment: ArrayBuffer | Uint8Array): Promise<models.Receipt> {\n const encryptedData = await this.crypto.entities.encryptDataOf(receipt, attachment)\n return await this.setReceiptAttachment(receipt.id!, blobType, undefined, encryptedData)\n }\n\n /**\n * Adds an unencrypted attachment to a receipt.\n * @param receipt a receipt.\n * @param blobType the type of the attachment.\n * @param attachment a attachment for the receipt.\n * @return the updated receipt.\n */\n async setClearReceiptAttachment(receipt: models.Receipt, blobType: string, attachment: ArrayBuffer | Uint8Array): Promise<models.Receipt> {\n return await this.setReceiptAttachment(receipt.id!, blobType, undefined, attachment)\n }\n\n /**\n * Gets the attachment of a receipt and tries to decrypt it using the encryption keys of the receipt, throwing an error if the operation fails.\n * @param receipt a receipt.\n * @param attachmentId id of the attachment of this receipt to retrieve.\n * @param validator optionally a validator function which checks if the decryption was successful. In cases where the receipt has many encryption\n * keys and it is unclear which one should be used this function can help to detect bad decryptions.\n * @return the decrypted attachment, if it could be decrypted, else the encrypted attachment.\n */\n async getAndDecryptReceiptAttachment(\n receipt: models.Receipt,\n attachmentId: string,\n validator: (decrypted: ArrayBuffer) => Promise<boolean> = () => Promise.resolve(true)\n ): Promise<ArrayBuffer> {\n const { data, wasDecrypted } = await this.crypto.entities.tryDecryptDataOf(\n receipt,\n await this.getReceiptAttachment(receipt.id!, attachmentId, ''),\n (x) => validator(x)\n )\n if (!wasDecrypted) throw new Error(`No valid key found to decrypt data of receipt ${receipt.id}.`)\n return data\n }\n\n /**\n * Gets the attachment of a receipt and tries to decrypt it using the encryption keys of the receipt.\n * @param receipt a receipt.\n * @param attachmentId id of the attachment of this receipt to retrieve.\n * @param validator optionally a validator function which checks if the decryption was successful. In cases where the receipt has many encryption\n * keys and it is unclear which one should be used this function can help to detect bad decryptions.\n * @return an object containing:\n * - data: the decrypted attachment, if it could be decrypted, else the encrypted attachment.\n * - wasDecrypted: if the data was successfully decrypted or not\n */\n async getAndTryDecryptReceiptAttachment(\n receipt: models.Receipt,\n attachmentId: string,\n validator: (decrypted: ArrayBuffer) => Promise<boolean> = () => Promise.resolve(true)\n ): Promise<{ data: ArrayBuffer; wasDecrypted: boolean }> {\n return await this.crypto.entities.tryDecryptDataOf(receipt, await this.getReceiptAttachment(receipt.id!, attachmentId, ''), (x) => validator(x))\n }\n\n /**\n * Share an existing receipt with other data owners, allowing them to access the non-encrypted data of the receipt and optionally also\n * the encrypted content.\n * @param delegateId the id of the data owner which will be granted access to the receipt.\n * @param receipt the receipt to share.\n * @param options optional parameters to customize the sharing behaviour:\n * - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted\n * content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a\n * receipt does not have encrypted content.\n * @return a promise which will contain the updated receipt.\n */\n async shareWith(\n delegateId: string,\n receipt: models.Receipt,\n options: {\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n } = {}\n ): Promise<models.Receipt> {\n return this.shareWithMany(receipt, { [delegateId]: options })\n }\n\n /**\n * Share an existing receipt with other data owners, allowing them to access the non-encrypted data of the receipt and optionally also\n * the encrypted content.\n * @param receipt the receipt to share.\n * @param delegates sharing options for each delegate which will gain access to the entity:\n * - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted\n * content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a\n * receipt does not have encrypted content.\n * @return a promise which will contain the updated receipt.\n */\n async shareWithMany(\n receipt: models.Receipt,\n delegates: {\n [delegateId: string]: {\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n }\n }\n ): Promise<models.Receipt> {\n const extended = await this.crypto.entities.entityWithAutoExtendedEncryptedMetadata(receipt, true, delegates)\n if (!!extended) {\n return await this.modifyReceipt(extended)\n } else return receipt\n }\n\n async getDataOwnersWithAccessTo(entity: models.Receipt): Promise<{\n permissionsByDataOwnerId: { [dataOwnerId: string]: 'WRITE' }\n hasUnknownAnonymousDataOwners: boolean\n }> {\n return await this.crypto.entities.getDataOwnersWithAccessTo(entity)\n }\n\n async getEncryptionKeysOf(entity: models.Receipt): Promise<string[]> {\n return await this.crypto.entities.encryptionKeysOf(entity)\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"icc-receipt-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-receipt-x-api.ts"],"names":[],"mappings":";;;;;;;;;;;;AA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,OAAO,CAAC,IAAI,CAAC;;YAErF,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAC,OAAO,EAAE,MAAM,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,EAAG,EAAE,YAAY,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAA;QAClJ,CAAC;KAAA;IAED;;;;;;;;;;OAUG;IACG,SAAS,CACb,UAAkB,EAClB,OAAuB,EACvB,UAEI,EAAE;;YAEN,OAAO,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,CAAC,CAAA;QAC/D,CAAC;KAAA;IAED;;;;;;;;;OASG;IACG,aAAa,CACjB,OAAuB,EACvB,SAIC;;YAED,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,uCAAuC,CAAC,OAAO,EAAE,IAAI,EAAE,SAAS,CAAC,CAAA;YAC7G,IAAI,CAAC,CAAC,QAAQ,EAAE;gBACd,OAAO,MAAM,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;aAC1C;;gBAAM,OAAO,OAAO,CAAA;QACvB,CAAC;KAAA;IAEK,yBAAyB,CAAC,MAAsB;;YAIpD,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,yBAAyB,CAAC,MAAM,CAAC,CAAA;QACrE,CAAC;KAAA;IAEK,mBAAmB,CAAC,MAAsB;;YAC9C,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAA;QAC5D,CAAC;KAAA;CACF;AA1LD,wCA0LC","sourcesContent":["import { IccReceiptApi } from '../icc-api'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\nimport * as _ from 'lodash'\nimport * as models from '../icc-api/model/models'\nimport { IccDataOwnerXApi } from './icc-data-owner-x-api'\nimport { AuthenticationProvider, NoAuthenticationProvider } from './auth/AuthenticationProvider'\nimport { ShareMetadataBehaviour } from './crypto/ShareMetadataBehaviour'\nimport { EncryptedEntityXApi } from './basexapi/EncryptedEntityXApi'\n\nexport class IccReceiptXApi extends IccReceiptApi implements EncryptedEntityXApi<models.Receipt> {\n dataOwnerApi: IccDataOwnerXApi\n\n constructor(\n host: string,\n headers: { [key: string]: string },\n private crypto: IccCryptoXApi,\n dataOwnerApi: IccDataOwnerXApi,\n authenticationProvider: AuthenticationProvider = new NoAuthenticationProvider(),\n fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response> = typeof window !== 'undefined'\n ? window.fetch\n : typeof self !== 'undefined'\n ? self.fetch\n : fetch\n ) {\n super(host, headers, authenticationProvider, fetchImpl)\n this.dataOwnerApi = dataOwnerApi\n }\n\n /**\n * Creates a new instance of receipt with initialised encryption metadata (not in the database).\n * @param user the current user.\n * @param r initialised data for the receipt. Metadata such as id, creation data, etc. will be automatically initialised, but you can specify\n * other kinds of data or overwrite generated metadata with this. You can't specify encryption metadata.\n * @param options optional parameters:\n * - additionalDelegates: delegates which will have access to the entity in addition to the current data owner and delegates from the\n * auto-delegations. Must be an object which associates each data owner id with the access level to give to that data owner. May overlap with\n * auto-delegations, in such case the access level specified here will be used. Currently only WRITE access is supported, but in future also read\n * access will be possible.\n * @return a new instance of receipt.\n */\n async newInstance(\n user: models.User,\n r: any,\n options: {\n additionalDelegates?: { [dataOwnerId: string]: 'WRITE' }\n } = {}\n ): Promise<models.Receipt> {\n const receipt = new models.Receipt({\n ...(r ?? {}),\n _type: 'org.taktik.icure.entities.Receipt',\n id: r?.id ?? this.crypto.randomUuid(),\n created: r?.created ?? new Date().getTime(),\n modified: r?.modified ?? new Date().getTime(),\n responsible: r?.responsible ?? this.dataOwnerApi.getDataOwnerIdOf(user),\n author: r?.author ?? user.id,\n codes: r?.codes ?? [],\n tags: r?.tags ?? [],\n })\n\n const extraDelegations = [\n ...Object.keys(options.additionalDelegates ?? {}),\n ...(user.autoDelegations?.all ?? []),\n ...(user.autoDelegations?.medicalInformation ?? []),\n ]\n return new models.Receipt(\n await this.crypto.entities\n .entityWithInitialisedEncryptedMetadata(receipt, undefined, undefined, true, extraDelegations)\n .then((x) => x.updatedEntity)\n )\n }\n\n logReceipt(user: models.User, docId: string, refs: Array<string>, blobType: string, blob: ArrayBuffer) {\n return this.newInstance(user, { documentId: docId, references: refs })\n .then((rcpt) => this.createReceipt(rcpt))\n .then((rcpt) => (blob.byteLength != 0 ? this.setReceiptAttachment(rcpt.id!, blobType, '', <any>blob) : Promise.resolve(rcpt)))\n }\n\n /**\n * Adds an attachment to a receipt, encrypting it on client side using the encryption keys of the provided receipt.\n * @param receipt a receipt.\n * @param blobType the type of the attachment.\n * @param attachment a attachment for the receipt.\n * @return the updated receipt.\n */\n async encryptAndSetReceiptAttachment(receipt: models.Receipt, blobType: string, attachment: ArrayBuffer | Uint8Array): Promise<models.Receipt> {\n const encryptedData = await this.crypto.entities.encryptDataOf(receipt, attachment)\n return await this.setReceiptAttachment(receipt.id!, blobType, undefined, encryptedData)\n }\n\n /**\n * Adds an unencrypted attachment to a receipt.\n * @param receipt a receipt.\n * @param blobType the type of the attachment.\n * @param attachment a attachment for the receipt.\n * @return the updated receipt.\n */\n async setClearReceiptAttachment(receipt: models.Receipt, blobType: string, attachment: ArrayBuffer | Uint8Array): Promise<models.Receipt> {\n return await this.setReceiptAttachment(receipt.id!, blobType, undefined, attachment)\n }\n\n /**\n * Gets the attachment of a receipt and tries to decrypt it using the encryption keys of the receipt, throwing an error if the operation fails.\n * @param receipt a receipt.\n * @param attachmentId id of the attachment of this receipt to retrieve.\n * @param validator optionally a validator function which checks if the decryption was successful. In cases where the receipt has many encryption\n * keys and it is unclear which one should be used this function can help to detect bad decryptions.\n * @return the decrypted attachment, if it could be decrypted, else the encrypted attachment.\n */\n async getAndDecryptReceiptAttachment(\n receipt: models.Receipt,\n attachmentId: string,\n validator: (decrypted: ArrayBuffer) => Promise<boolean> = () => Promise.resolve(true)\n ): Promise<ArrayBuffer> {\n const { data, wasDecrypted } = await this.crypto.entities.tryDecryptDataOf(\n receipt,\n await this.getReceiptAttachment(receipt.id!, attachmentId, ''),\n (x) => validator(x)\n )\n if (!wasDecrypted) throw new Error(`No valid key found to decrypt data of receipt ${receipt.id}.`)\n return data\n }\n\n /**\n * Gets the attachment of a receipt and tries to decrypt it using the encryption keys of the receipt.\n * @param receipt a receipt.\n * @param attachmentId id of the attachment of this receipt to retrieve.\n * @param validator optionally a validator function which checks if the decryption was successful. In cases where the receipt has many encryption\n * keys and it is unclear which one should be used this function can help to detect bad decryptions.\n * @return an object containing:\n * - data: the decrypted attachment, if it could be decrypted, else the encrypted attachment.\n * - wasDecrypted: if the data was successfully decrypted or not\n */\n async getAndTryDecryptReceiptAttachment(\n receipt: models.Receipt,\n attachmentId: string,\n validator: (decrypted: ArrayBuffer) => Promise<boolean> = () => Promise.resolve(true)\n ): Promise<{ data: ArrayBuffer; wasDecrypted: boolean }> {\n return await this.crypto.entities.tryDecryptDataOf(receipt, await this.getReceiptAttachment(receipt.id!, attachmentId, ''), (x) => validator(x))\n }\n\n /**\n * Share an existing receipt with other data owners, allowing them to access the non-encrypted data of the receipt and optionally also\n * the encrypted content.\n * @param delegateId the id of the data owner which will be granted access to the receipt.\n * @param receipt the receipt to share.\n * @param options optional parameters to customize the sharing behaviour:\n * - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted\n * content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a\n * receipt does not have encrypted content.\n * @return a promise which will contain the updated receipt.\n */\n async shareWith(\n delegateId: string,\n receipt: models.Receipt,\n options: {\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n } = {}\n ): Promise<models.Receipt> {\n return this.shareWithMany(receipt, { [delegateId]: options })\n }\n\n /**\n * Share an existing receipt with other data owners, allowing them to access the non-encrypted data of the receipt and optionally also\n * the encrypted content.\n * @param receipt the receipt to share.\n * @param delegates sharing options for each delegate which will gain access to the entity:\n * - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted\n * content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a\n * receipt does not have encrypted content.\n * @return a promise which will contain the updated receipt.\n */\n async shareWithMany(\n receipt: models.Receipt,\n delegates: {\n [delegateId: string]: {\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n }\n }\n ): Promise<models.Receipt> {\n const extended = await this.crypto.entities.entityWithAutoExtendedEncryptedMetadata(receipt, true, delegates)\n if (!!extended) {\n return await this.modifyReceipt(extended)\n } else return receipt\n }\n\n async getDataOwnersWithAccessTo(entity: models.Receipt): Promise<{\n permissionsByDataOwnerId: { [dataOwnerId: string]: 'WRITE' }\n hasUnknownAnonymousDataOwners: boolean\n }> {\n return await this.crypto.entities.getDataOwnersWithAccessTo(entity)\n }\n\n async getEncryptionKeysOf(entity: models.Receipt): Promise<string[]> {\n return await this.crypto.entities.encryptionKeysOf(entity)\n }\n}\n"]}
|
|
@@ -11,7 +11,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.IccTimeTableXApi = void 0;
|
|
13
13
|
const i18n = require("./rsrc/contact.i18n");
|
|
14
|
-
const _ = require("lodash");
|
|
15
14
|
const icc_api_1 = require("../icc-api");
|
|
16
15
|
const models = require("../icc-api/model/models");
|
|
17
16
|
const AuthenticationProvider_1 = require("./auth/AuthenticationProvider");
|
|
@@ -39,22 +38,13 @@ class IccTimeTableXApi extends icc_api_1.IccTimeTableApi {
|
|
|
39
38
|
* @return a new instance of timetable.
|
|
40
39
|
*/
|
|
41
40
|
newInstance(user, tt, options = {}) {
|
|
42
|
-
var _a, _b, _c, _d, _e;
|
|
41
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
43
42
|
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
-
const timeTable =
|
|
45
|
-
id: this.crypto.primitives.randomUuid(),
|
|
46
|
-
_type: 'org.taktik.icure.entities.TimeTable',
|
|
47
|
-
created: new Date().getTime(),
|
|
48
|
-
modified: new Date().getTime(),
|
|
49
|
-
responsible: this.dataOwnerApi.getDataOwnerIdOf(user),
|
|
50
|
-
author: user.id,
|
|
51
|
-
codes: [],
|
|
52
|
-
tags: [],
|
|
53
|
-
}, tt || {});
|
|
43
|
+
const timeTable = Object.assign(Object.assign({}, (tt !== null && tt !== void 0 ? tt : {})), { _type: 'org.taktik.icure.entities.TimeTable', id: (_a = tt === null || tt === void 0 ? void 0 : tt.id) !== null && _a !== void 0 ? _a : this.crypto.primitives.randomUuid(), created: (_b = tt === null || tt === void 0 ? void 0 : tt.created) !== null && _b !== void 0 ? _b : new Date().getTime(), modified: (_c = tt === null || tt === void 0 ? void 0 : tt.modified) !== null && _c !== void 0 ? _c : new Date().getTime(), responsible: (_d = tt === null || tt === void 0 ? void 0 : tt.responsible) !== null && _d !== void 0 ? _d : this.dataOwnerApi.getDataOwnerIdOf(user), author: (_e = tt === null || tt === void 0 ? void 0 : tt.author) !== null && _e !== void 0 ? _e : user.id, codes: (_f = tt === null || tt === void 0 ? void 0 : tt.codes) !== null && _f !== void 0 ? _f : [], tags: (_g = tt === null || tt === void 0 ? void 0 : tt.tags) !== null && _g !== void 0 ? _g : [] });
|
|
54
44
|
const extraDelegations = [
|
|
55
|
-
...Object.keys((
|
|
56
|
-
...((
|
|
57
|
-
...((
|
|
45
|
+
...Object.keys((_h = options.additionalDelegates) !== null && _h !== void 0 ? _h : {}),
|
|
46
|
+
...((_k = (_j = user.autoDelegations) === null || _j === void 0 ? void 0 : _j.all) !== null && _k !== void 0 ? _k : []),
|
|
47
|
+
...((_m = (_l = user.autoDelegations) === null || _l === void 0 ? void 0 : _l.administrativeData) !== null && _m !== void 0 ? _m : []),
|
|
58
48
|
];
|
|
59
49
|
return new models.TimeTable(yield this.crypto.entities
|
|
60
50
|
.entityWithInitialisedEncryptedMetadata(timeTable, undefined, undefined, true, extraDelegations)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icc-time-table-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-time-table-x-api.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4CAA2C;
|
|
1
|
+
{"version":3,"file":"icc-time-table-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-time-table-x-api.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4CAA2C;AAG3C,wCAA4C;AAK5C,kDAAiD;AACjD,0EAAgG;AAIhG,MAAa,gBAAiB,SAAQ,yBAAe;IAKnD,YACE,IAAY,EACZ,OAAkC,EAClC,MAAqB,EACrB,YAA8B,EAC9B,yBAAiD,IAAI,iDAAwB,EAAE,EAC/E,YAA2E,OAAO,MAAM,KAAK,WAAW;QACtG,CAAC,CAAC,MAAM,CAAC,KAAK;QACd,CAAC,CAAC,OAAO,IAAI,KAAK,WAAW;YAC7B,CAAC,CAAC,IAAI,CAAC,KAAK;YACZ,CAAC,CAAC,KAAK;QAET,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,sBAAsB,EAAE,SAAS,CAAC,CAAA;QAhBzD,SAAI,GAAQ,IAAI,CAAA;QAiBd,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;IAClC,CAAC;IAED;;;;;;;;;;;OAWG;IACG,WAAW,CACf,IAAU,EACV,EAAa,EACb,UAEI,EAAE;;;YAEN,MAAM,SAAS,mCACV,CAAC,EAAE,aAAF,EAAE,cAAF,EAAE,GAAI,EAAE,CAAC,KACb,KAAK,EAAE,qCAAqC,EAC5C,EAAE,EAAE,MAAA,EAAE,aAA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AChC,CAAA;;KACF;IAED;;;;;;;;;;;OAWG;IACG,SAAS,CACb,UAAkB,EAClB,SAA2B,EAC3B,UAEI,EAAE;;YAEN,OAAO,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE,EAAE,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,CAAC,CAAA;QACjE,CAAC;KAAA;IAED;;;;;;;;;;OAUG;IACG,aAAa,CACjB,SAA2B,EAC3B,SAIC;;YAED,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,uCAAuC,CAAC,SAAS,EAAE,IAAI,EAAE,SAAS,CAAC,CAAA;YAC/G,IAAI,CAAC,CAAC,QAAQ,EAAE;gBACd,OAAO,MAAM,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAA;aAC5C;;gBAAM,OAAO,SAAS,CAAA;QACzB,CAAC;KAAA;IAEK,yBAAyB,CAC7B,MAAwB;;YAExB,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,yBAAyB,CAAC,MAAM,CAAC,CAAA;QACrE,CAAC;KAAA;IAEK,mBAAmB,CAAC,MAAwB;;YAChD,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAA;QAC5D,CAAC;KAAA;CACF;AAzHD,4CAyHC","sourcesContent":["import * as i18n from './rsrc/contact.i18n'\n\nimport * as _ from 'lodash'\nimport { IccTimeTableApi } from '../icc-api'\nimport { User } from '../icc-api/model/User'\nimport { TimeTable } from '../icc-api/model/TimeTable'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\nimport { IccDataOwnerXApi } from './icc-data-owner-x-api'\nimport * as models from '../icc-api/model/models'\nimport { AuthenticationProvider, NoAuthenticationProvider } from './auth/AuthenticationProvider'\nimport { ShareMetadataBehaviour } from './crypto/ShareMetadataBehaviour'\nimport { EncryptedEntityXApi } from './basexapi/EncryptedEntityXApi'\n\nexport class IccTimeTableXApi extends IccTimeTableApi implements EncryptedEntityXApi<TimeTable> {\n i18n: any = i18n\n crypto: IccCryptoXApi\n dataOwnerApi: IccDataOwnerXApi\n\n constructor(\n host: string,\n headers: { [key: string]: string },\n crypto: IccCryptoXApi,\n dataOwnerApi: IccDataOwnerXApi,\n authenticationProvider: AuthenticationProvider = new NoAuthenticationProvider(),\n fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response> = typeof window !== 'undefined'\n ? window.fetch\n : typeof self !== 'undefined'\n ? self.fetch\n : fetch\n ) {\n super(host, headers, authenticationProvider, fetchImpl)\n this.crypto = crypto\n this.dataOwnerApi = dataOwnerApi\n }\n\n /**\n * Creates a new instance of timetable with initialised encryption metadata (not in the database).\n * @param user the current user.\n * @param tt initialised data for the timetable. Metadata such as id, creation data, etc. will be automatically initialised, but you can specify\n * other kinds of data or overwrite generated metadata with this. You can't specify encryption metadata.\n * @param options optional parameters:\n * - additionalDelegates: delegates which will have access to the entity in addition to the current data owner and delegates from the\n * auto-delegations. Must be an object which associates each data owner id with the access level to give to that data owner. May overlap with\n * auto-delegations, in such case the access level specified here will be used. Currently only WRITE access is supported, but in future also read\n * access will be possible.\n * @return a new instance of timetable.\n */\n async newInstance(\n user: User,\n tt: TimeTable,\n options: {\n additionalDelegates?: { [dataOwnerId: string]: 'WRITE' }\n } = {}\n ) {\n const timeTable = {\n ...(tt ?? {}),\n _type: 'org.taktik.icure.entities.TimeTable',\n id: tt?.id ?? this.crypto.primitives.randomUuid(),\n created: tt?.created ?? new Date().getTime(),\n modified: tt?.modified ?? new Date().getTime(),\n responsible: tt?.responsible ?? this.dataOwnerApi.getDataOwnerIdOf(user),\n author: tt?.author ?? user.id,\n codes: tt?.codes ?? [],\n tags: tt?.tags ?? [],\n }\n\n const extraDelegations = [\n ...Object.keys(options.additionalDelegates ?? {}),\n ...(user.autoDelegations?.all ?? []),\n ...(user.autoDelegations?.administrativeData ?? []),\n ]\n return new models.TimeTable(\n await this.crypto.entities\n .entityWithInitialisedEncryptedMetadata(timeTable, undefined, undefined, true, extraDelegations)\n .then((x) => x.updatedEntity)\n )\n }\n\n /**\n * Share an existing time table with other data owners, allowing them to access the non-encrypted data of the time table and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param delegateId the id of the data owner which will be granted access to the time table.\n * @param timeTable the time table to share.\n * @param options optional parameters to customize the sharing behaviour:\n * - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted\n * content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a\n * time table does not have encrypted content.\n * @return a promise which will contain the result of the operation: the updated entity if the operation was successful or details of the error if\n * the operation failed.\n */\n async shareWith(\n delegateId: string,\n timeTable: models.TimeTable,\n options: {\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n } = {}\n ): Promise<models.TimeTable> {\n return this.shareWithMany(timeTable, { [delegateId]: options })\n }\n\n /**\n * Share an existing time table with other data owners, allowing them to access the non-encrypted data of the time table and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param timeTable the time table to share.\n * @param delegates sharing options for each delegate.\n * - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted\n * content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a\n * time table does not have encrypted content.\n * @return a promise which will contain the result of the operation: the updated entity if the operation was successful or details of the error if\n * the operation failed.\n */\n async shareWithMany(\n timeTable: models.TimeTable,\n delegates: {\n [delegateId: string]: {\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n }\n }\n ): Promise<models.TimeTable> {\n const extended = await this.crypto.entities.entityWithAutoExtendedEncryptedMetadata(timeTable, true, delegates)\n if (!!extended) {\n return await this.modifyTimeTable(extended)\n } else return timeTable\n }\n\n async getDataOwnersWithAccessTo(\n entity: models.TimeTable\n ): Promise<{ permissionsByDataOwnerId: { [p: string]: 'WRITE' }; hasUnknownAnonymousDataOwners: boolean }> {\n return await this.crypto.entities.getDataOwnersWithAccessTo(entity)\n }\n\n async getEncryptionKeysOf(entity: models.TimeTable): Promise<string[]> {\n return await this.crypto.entities.encryptionKeysOf(entity)\n }\n}\n"]}
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import { IccUserApi } from '../icc-api/api/IccUserApi';
|
|
2
2
|
import { AuthenticationProvider } from './auth/AuthenticationProvider';
|
|
3
|
+
import { AbstractFilter } from "./filters/filters";
|
|
4
|
+
import { User } from "../icc-api/model/User";
|
|
5
|
+
import { Connection } from "../icc-api/model/Connection";
|
|
6
|
+
import { IccAuthApi } from "../icc-api";
|
|
3
7
|
export declare class IccUserXApi extends IccUserApi {
|
|
4
8
|
fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response>;
|
|
9
|
+
authApi: IccAuthApi;
|
|
5
10
|
constructor(host: string, headers: {
|
|
6
11
|
[key: string]: string;
|
|
7
|
-
}, authenticationProvider
|
|
12
|
+
}, authenticationProvider: AuthenticationProvider | undefined, authApi: IccAuthApi, fetchImpl?: (input: RequestInfo, init?: RequestInit) => Promise<Response>);
|
|
13
|
+
subscribeToUserEvents(eventTypes: ('CREATE' | 'UPDATE' | 'DELETE')[], filter: AbstractFilter<User> | undefined, eventFired: (user: User) => Promise<void>, options?: {
|
|
14
|
+
connectionMaxRetry?: number;
|
|
15
|
+
connectionRetryIntervalMs?: number;
|
|
16
|
+
}): Promise<Connection>;
|
|
8
17
|
}
|
|
@@ -3,14 +3,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.IccUserXApi = void 0;
|
|
4
4
|
const IccUserApi_1 = require("../icc-api/api/IccUserApi");
|
|
5
5
|
const AuthenticationProvider_1 = require("./auth/AuthenticationProvider");
|
|
6
|
+
const Connection_1 = require("../icc-api/model/Connection");
|
|
7
|
+
const websocket_1 = require("./utils/websocket");
|
|
6
8
|
class IccUserXApi extends IccUserApi_1.IccUserApi {
|
|
7
|
-
constructor(host, headers, authenticationProvider = new AuthenticationProvider_1.NoAuthenticationProvider(), fetchImpl = typeof window !== 'undefined'
|
|
9
|
+
constructor(host, headers, authenticationProvider = new AuthenticationProvider_1.NoAuthenticationProvider(), authApi, fetchImpl = typeof window !== 'undefined'
|
|
8
10
|
? window.fetch
|
|
9
11
|
: typeof self !== 'undefined'
|
|
10
12
|
? self.fetch
|
|
11
13
|
: fetch) {
|
|
12
14
|
super(host, headers, authenticationProvider, fetchImpl);
|
|
13
15
|
this.fetchImpl = fetchImpl;
|
|
16
|
+
this.authApi = authApi;
|
|
17
|
+
}
|
|
18
|
+
subscribeToUserEvents(eventTypes, filter, eventFired, options = {}) {
|
|
19
|
+
return (0, websocket_1.subscribeToEntityEvents)(this.host, this.authApi, 'User', eventTypes, filter, eventFired, options)
|
|
20
|
+
.then((rs) => new Connection_1.ConnectionImpl(rs));
|
|
14
21
|
}
|
|
15
22
|
}
|
|
16
23
|
exports.IccUserXApi = IccUserXApi;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icc-user-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-user-x-api.ts"],"names":[],"mappings":";;;AAAA,0DAAsD;AACtD,0EAAgG;
|
|
1
|
+
{"version":3,"file":"icc-user-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-user-x-api.ts"],"names":[],"mappings":";;;AAAA,0DAAsD;AACtD,0EAAgG;AAGhG,4DAAsE;AACtE,iDAAyD;AAGzD,MAAa,WAAY,SAAQ,uBAAU;IAIzC,YACE,IAAY,EACZ,OAAkC,EAClC,yBAAiD,IAAI,iDAAwB,EAAE,EAC/E,OAAmB,EACnB,YAA2E,OAAO,MAAM,KAAK,WAAW;QACtG,CAAC,CAAC,MAAM,CAAC,KAAK;QACd,CAAC,CAAC,OAAO,IAAI,KAAK,WAAW;YAC7B,CAAC,CAAC,IAAI,CAAC,KAAK;YACZ,CAAC,CAAC,KAAK;QAET,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,sBAAsB,EAAE,SAAS,CAAC,CAAA;QACvD,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;QAC1B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;IAED,qBAAqB,CACnB,UAA8C,EAC9C,MAAwC,EACxC,UAAyC,EACzC,UAA+E,EAAE;QAEjF,OAAO,IAAA,mCAAuB,EAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC;aACrG,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,2BAAc,CAAC,EAAE,CAAC,CAAC,CAAA;IACzC,CAAC;CACF;AA7BD,kCA6BC","sourcesContent":["import { IccUserApi } from '../icc-api/api/IccUserApi'\nimport { AuthenticationProvider, NoAuthenticationProvider } from './auth/AuthenticationProvider'\nimport {AbstractFilter} from \"./filters/filters\"\nimport {User} from \"../icc-api/model/User\"\nimport {Connection, ConnectionImpl} from \"../icc-api/model/Connection\"\nimport {subscribeToEntityEvents} from \"./utils/websocket\"\nimport {IccAuthApi} from \"../icc-api\"\n\nexport class IccUserXApi extends IccUserApi {\n fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response>\n authApi: IccAuthApi\n\n constructor(\n host: string,\n headers: { [key: string]: string },\n authenticationProvider: AuthenticationProvider = new NoAuthenticationProvider(),\n authApi: IccAuthApi,\n fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response> = typeof window !== 'undefined'\n ? window.fetch\n : typeof self !== 'undefined'\n ? self.fetch\n : fetch\n ) {\n super(host, headers, authenticationProvider, fetchImpl)\n this.fetchImpl = fetchImpl\n this.authApi = authApi\n }\n\n subscribeToUserEvents(\n eventTypes: ('CREATE' | 'UPDATE' | 'DELETE')[],\n filter: AbstractFilter<User> | undefined,\n eventFired: (user: User) => Promise<void>,\n options: { connectionMaxRetry?: number; connectionRetryIntervalMs?: number } = {}\n ): Promise<Connection> {\n return subscribeToEntityEvents(this.host, this.authApi, 'User', eventTypes, filter, eventFired, options)\n .then((rs) => new ConnectionImpl(rs))\n }\n}\n"]}
|
package/icc-x-api/index.d.ts
CHANGED
|
@@ -14,7 +14,6 @@ import { IccMessageXApi } from './icc-message-x-api';
|
|
|
14
14
|
import { IccReceiptXApi } from './icc-receipt-x-api';
|
|
15
15
|
import { IccAccesslogXApi } from './icc-accesslog-x-api';
|
|
16
16
|
import { IccTimeTableXApi } from './icc-time-table-x-api';
|
|
17
|
-
import { IccDeviceApi } from '../icc-api';
|
|
18
17
|
import { IccCodeXApi } from './icc-code-x-api';
|
|
19
18
|
import { IccMaintenanceTaskXApi } from './icc-maintenance-task-x-api';
|
|
20
19
|
import { IccDataOwnerXApi } from './icc-data-owner-x-api';
|
|
@@ -27,6 +26,7 @@ import { IccIcureMaintenanceXApi } from './icc-icure-maintenance-x-api';
|
|
|
27
26
|
import { IccBekmehrXApi } from './icc-bekmehr-x-api';
|
|
28
27
|
import { IccDoctemplateXApi } from './icc-doctemplate-x-api';
|
|
29
28
|
import { UserGroup } from '../icc-api/model/UserGroup';
|
|
29
|
+
import { IccDeviceXApi } from "./icc-device-x-api";
|
|
30
30
|
export * from './icc-accesslog-x-api';
|
|
31
31
|
export * from './icc-bekmehr-x-api';
|
|
32
32
|
export * from './icc-calendar-item-x-api';
|
|
@@ -60,7 +60,7 @@ export interface Apis {
|
|
|
60
60
|
readonly userApi: IccUserXApi;
|
|
61
61
|
readonly permissionApi: IccPermissionApi;
|
|
62
62
|
readonly healthcarePartyApi: IccHcpartyXApi;
|
|
63
|
-
readonly deviceApi:
|
|
63
|
+
readonly deviceApi: IccDeviceXApi;
|
|
64
64
|
readonly cryptoApi: IccCryptoXApi;
|
|
65
65
|
readonly accessLogApi: IccAccesslogXApi;
|
|
66
66
|
readonly agendaApi: IccAgendaApi;
|
|
@@ -149,9 +149,98 @@ export interface IcureApiOptions {
|
|
|
149
149
|
}
|
|
150
150
|
/**
|
|
151
151
|
* Specifies which fields should be encrypted for each kind of encryptable entity.
|
|
152
|
+
*
|
|
152
153
|
* Note that any value you specify here overrides the default values. For example if you specify `['medicalLocationId']` for `healthElement` the
|
|
153
154
|
* fields `['descr', 'note']` which are usually encrypted by default will no longer be encrypted. If you want to add fields to the default values
|
|
154
155
|
* you can use {@link EncryptedFieldsConfig.Defaults}, for example `[...EncryptedFieldsConfig.Defaults.healthElement, 'medicalLocationId'].
|
|
156
|
+
*
|
|
157
|
+
* # Encrypted fields syntax
|
|
158
|
+
*
|
|
159
|
+
* ## Grammar
|
|
160
|
+
*
|
|
161
|
+
* The grammar for each encrypted field is the following:
|
|
162
|
+
* ```
|
|
163
|
+
* fieldName :=
|
|
164
|
+
* regex([a-zA-Z_][a-zA-Z0-9_]+)
|
|
165
|
+
* encryptedField :=
|
|
166
|
+
* fieldName
|
|
167
|
+
* | fieldName + ("." | ".*." | "[].") + encryptedField
|
|
168
|
+
* ```
|
|
169
|
+
*
|
|
170
|
+
* This grammar allows you to specify the fields to encrypt for the object and recursively for nested objects.
|
|
171
|
+
* - A string containing only a single `fieldName` will encrypt the field with the given name.
|
|
172
|
+
* - A string starting with `fieldName.` allows to specify the encrypted fields of a nested object. The encrypted values of the
|
|
173
|
+
* fields in the nested object will be saved in the nested object.
|
|
174
|
+
* - A string starting with `fieldName.*.` treats `fieldName` as a map/dictionary data structure and allows to specify the encrypted fields of the
|
|
175
|
+
* values of the map. Note that the values of the map must be objects as well. The encrypted content of each map value is stored in that value.
|
|
176
|
+
* - A string starting with `fieldName[].` treats `fieldName` as an array and allows to specify the encrypted fields of the values of the array.
|
|
177
|
+
* Note that the values of the array must be objects as well. The encrypted content of each array element is stored in that element.
|
|
178
|
+
*
|
|
179
|
+
* ## Example
|
|
180
|
+
*
|
|
181
|
+
* Consider the following object and encryption keys:
|
|
182
|
+
* ```javascript
|
|
183
|
+
* const obj = {
|
|
184
|
+
* a: { x: 0, y: 1 },
|
|
185
|
+
* b: "hello",
|
|
186
|
+
* c: [ { public: "a", secret: "b" }, { public: "c", secret: "d" } ],
|
|
187
|
+
* d: "ok",
|
|
188
|
+
* e: {
|
|
189
|
+
* info: "something",
|
|
190
|
+
* private: "secret",
|
|
191
|
+
* dataMap: {
|
|
192
|
+
* "en": {
|
|
193
|
+
* a: 1,
|
|
194
|
+
* b: 2
|
|
195
|
+
* },
|
|
196
|
+
* "fr": {
|
|
197
|
+
* a: 3,
|
|
198
|
+
* b: 4
|
|
199
|
+
* }
|
|
200
|
+
* }
|
|
201
|
+
* }
|
|
202
|
+
* }
|
|
203
|
+
* const encryptedFields = [
|
|
204
|
+
* "a",
|
|
205
|
+
* "c[].secret",
|
|
206
|
+
* "d",
|
|
207
|
+
* "e.private",
|
|
208
|
+
* "e.datamap.*.a"
|
|
209
|
+
* ]
|
|
210
|
+
* ```
|
|
211
|
+
* If you use them with the crypt method you will get the following result:
|
|
212
|
+
* ```json
|
|
213
|
+
* {
|
|
214
|
+
* b: "hello",
|
|
215
|
+
* c: [
|
|
216
|
+
* { public: "a", encryptedSelf: "...encrypted data of c[0]" },
|
|
217
|
+
* { public: "c", encryptedSelf: "...encrypted data of c[1]" }
|
|
218
|
+
* ],
|
|
219
|
+
* e: {
|
|
220
|
+
* info: "something",
|
|
221
|
+
* dataMap: {
|
|
222
|
+
* "en": { b: 2, encryptedSelf: "...encrypted data of e.dataMap['en']" },
|
|
223
|
+
* "fr": { b: 4, encryptedSelf: "...encrypted data of e.dataMap['fr']" }
|
|
224
|
+
* },
|
|
225
|
+
* encryptedSelf: "...encrypted data of e"
|
|
226
|
+
* },
|
|
227
|
+
* encryptedSelf: "...encrypted data of obj"
|
|
228
|
+
* }
|
|
229
|
+
* ```
|
|
230
|
+
*
|
|
231
|
+
* ## Shortened representation
|
|
232
|
+
*
|
|
233
|
+
* You can also group encrypted fields having the same prefix by concatenating to the prefix the JSON representation of an array of all the postfixes.
|
|
234
|
+
* For example the following encrypted fields:
|
|
235
|
+
* ```javascript
|
|
236
|
+
* const encryptedFields = ["a.b.c.d.e.f1", "a.b.c.d.e.f2", "a.b.c.d.e.f3", "a.b.c.d.e.f4"]
|
|
237
|
+
* ```
|
|
238
|
+
* can be shortened to
|
|
239
|
+
* ```javascript
|
|
240
|
+
* const encryptedFields = ['a.b.c.d.e.["f1","f2","f3","f4"]'] // Note the use of single quotes to avoid escaping the double quotes
|
|
241
|
+
* ```
|
|
242
|
+
* If you use the shortened representation you may need to escape nested json representations. In that case the use of `JSON.stringify` is
|
|
243
|
+
* recommended.
|
|
155
244
|
*/
|
|
156
245
|
export interface EncryptedFieldsConfig {
|
|
157
246
|
/**
|
|
@@ -164,9 +253,24 @@ export interface EncryptedFieldsConfig {
|
|
|
164
253
|
* @default ['details', 'title', 'patientId']
|
|
165
254
|
*/
|
|
166
255
|
readonly calendarItem?: string[];
|
|
256
|
+
/**
|
|
257
|
+
* Fields to encrypt for entities of type {@link Contact}, excluding `services`. You can specify which fields of `services` should be encrypted
|
|
258
|
+
* using {@link service}.
|
|
259
|
+
* @default ['descr'] // encryption of `services` is managed through {@link service}
|
|
260
|
+
*/
|
|
261
|
+
readonly contact?: string[];
|
|
262
|
+
/**
|
|
263
|
+
* Fields to encrypt for entities of type {@link Service}. Note that encryption of the `content` field and recursively contained `Services` through
|
|
264
|
+
* `content.compoundValue` is automatically managed by the sdk, and you are not allowed to modify it.
|
|
265
|
+
*
|
|
266
|
+
* Note: any non-empty values for this field will break bi-directional data compatibility between v7 and previous: Contacts created with
|
|
267
|
+
* v7 will not be read properly by previous versions. If you want
|
|
268
|
+
* @default ['notes[].markdown'] // encryption of `content` is managed in a special way
|
|
269
|
+
*/
|
|
270
|
+
readonly service?: string[];
|
|
167
271
|
/**
|
|
168
272
|
* Fields to encrypt for entities of type {@link HealthElement}
|
|
169
|
-
* @default ['descr', 'note']
|
|
273
|
+
* @default ['descr', 'note', 'notes[].markdown']
|
|
170
274
|
*/
|
|
171
275
|
readonly healthElement?: string[];
|
|
172
276
|
/**
|
|
@@ -176,7 +280,7 @@ export interface EncryptedFieldsConfig {
|
|
|
176
280
|
readonly maintenanceTask?: string[];
|
|
177
281
|
/**
|
|
178
282
|
* Fields to encrypt for entities of type {@link Patient}
|
|
179
|
-
* @default ['note']
|
|
283
|
+
* @default ['note', 'notes[].markdown']
|
|
180
284
|
*/
|
|
181
285
|
readonly patient?: string[];
|
|
182
286
|
}
|
|
@@ -184,6 +288,8 @@ export declare namespace EncryptedFieldsConfig {
|
|
|
184
288
|
const Defaults: {
|
|
185
289
|
accessLog: string[];
|
|
186
290
|
calendarItem: string[];
|
|
291
|
+
contact: string[];
|
|
292
|
+
service: string[];
|
|
187
293
|
healthElement: string[];
|
|
188
294
|
maintenanceTask: string[];
|
|
189
295
|
patient: string[];
|
package/icc-x-api/index.js
CHANGED
|
@@ -40,7 +40,6 @@ const icc_message_x_api_1 = require("./icc-message-x-api");
|
|
|
40
40
|
const icc_receipt_x_api_1 = require("./icc-receipt-x-api");
|
|
41
41
|
const icc_accesslog_x_api_1 = require("./icc-accesslog-x-api");
|
|
42
42
|
const icc_time_table_x_api_1 = require("./icc-time-table-x-api");
|
|
43
|
-
const icc_api_2 = require("../icc-api");
|
|
44
43
|
const icc_code_x_api_1 = require("./icc-code-x-api");
|
|
45
44
|
const icc_maintenance_task_x_api_1 = require("./icc-maintenance-task-x-api");
|
|
46
45
|
const icc_data_owner_x_api_1 = require("./icc-data-owner-x-api");
|
|
@@ -63,6 +62,7 @@ const utils_1 = require("./crypto/utils");
|
|
|
63
62
|
const CryptoActorStub_1 = require("../icc-api/model/CryptoActorStub");
|
|
64
63
|
const icc_bekmehr_x_api_1 = require("./icc-bekmehr-x-api");
|
|
65
64
|
const icc_doctemplate_x_api_1 = require("./icc-doctemplate-x-api");
|
|
65
|
+
const icc_device_x_api_1 = require("./icc-device-x-api");
|
|
66
66
|
__exportStar(require("./icc-accesslog-x-api"), exports);
|
|
67
67
|
__exportStar(require("./icc-bekmehr-x-api"), exports);
|
|
68
68
|
__exportStar(require("./icc-calendar-item-x-api"), exports);
|
|
@@ -113,10 +113,11 @@ var EncryptedFieldsConfig;
|
|
|
113
113
|
EncryptedFieldsConfig.Defaults = {
|
|
114
114
|
accessLog: ['detail', 'objectId'],
|
|
115
115
|
calendarItem: ['details', 'title', 'patientId'],
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
contact: ['descr'],
|
|
117
|
+
service: ['notes[].markdown'],
|
|
118
|
+
healthElement: ['descr', 'note', 'notes[].markdown'],
|
|
118
119
|
maintenanceTask: ['properties'],
|
|
119
|
-
patient: ['note'],
|
|
120
|
+
patient: ['note', 'notes[].markdown'],
|
|
120
121
|
};
|
|
121
122
|
})(EncryptedFieldsConfig = exports.EncryptedFieldsConfig || (exports.EncryptedFieldsConfig = {}));
|
|
122
123
|
var IcureApi;
|
|
@@ -141,7 +142,7 @@ var IcureApi;
|
|
|
141
142
|
else {
|
|
142
143
|
grouplessAuthenticationProvider = authenticationOptions;
|
|
143
144
|
}
|
|
144
|
-
const grouplessUserApi = new
|
|
145
|
+
const grouplessUserApi = new icc_api_1.IccUserApi(host, params.headers, grouplessAuthenticationProvider, fetchImpl);
|
|
145
146
|
const matches = yield grouplessUserApi.getMatchingUsers();
|
|
146
147
|
const chosenGroupId = matches.length > 1 ? yield params.groupSelector(matches) : matches[0].groupId;
|
|
147
148
|
/*TODO
|
|
@@ -158,8 +159,10 @@ var IcureApi;
|
|
|
158
159
|
function initialiseCryptoWithProvider(host, fetchImpl, groupSpecificAuthenticationProvider, params, cryptoStrategies, crypto) {
|
|
159
160
|
var _a, _b;
|
|
160
161
|
return __awaiter(this, void 0, void 0, function* () {
|
|
161
|
-
const
|
|
162
|
-
const
|
|
162
|
+
const authApi = new icc_api_1.IccAuthApi(host, params.headers, groupSpecificAuthenticationProvider, fetchImpl);
|
|
163
|
+
const userApi = new icc_user_x_api_1.IccUserXApi(host, params.headers, groupSpecificAuthenticationProvider, authApi, fetchImpl);
|
|
164
|
+
const healthcarePartyApi = new icc_hcparty_x_api_1.IccHcpartyXApi(host, params.headers, groupSpecificAuthenticationProvider, authApi, fetchImpl);
|
|
165
|
+
const deviceApi = new icc_device_x_api_1.IccDeviceXApi(host, params.headers, groupSpecificAuthenticationProvider, userApi, authApi, fetchImpl);
|
|
163
166
|
const basePatientApi = new icc_api_1.IccPatientApi(host, params.headers, groupSpecificAuthenticationProvider, fetchImpl);
|
|
164
167
|
const dataOwnerApi = new icc_data_owner_x_api_1.IccDataOwnerXApi(host, params.headers, groupSpecificAuthenticationProvider, fetchImpl);
|
|
165
168
|
// Crypto initialisation
|
|
@@ -177,9 +180,8 @@ function initialiseCryptoWithProvider(host, fetchImpl, groupSpecificAuthenticati
|
|
|
177
180
|
const confidentialEntitites = new ConfidentialEntities_1.ConfidentialEntities(entitiesEncryption, cryptoPrimitives, dataOwnerApi);
|
|
178
181
|
yield (0, utils_1.ensureDelegationForSelf)(dataOwnerApi, entitiesEncryption, cryptoPrimitives, basePatientApi);
|
|
179
182
|
const cryptoApi = new icc_crypto_x_api_1.IccCryptoXApi(exchangeKeysManager, cryptoPrimitives, keyManager, dataOwnerApi, entitiesEncryption, shamirManager, params.storage, params.keyStorage, icureStorage, healthcarePartyApi, confidentialEntitites);
|
|
180
|
-
const maintenanceTaskApi = new icc_maintenance_task_x_api_1.IccMaintenanceTaskXApi(host, params.headers, cryptoApi, healthcarePartyApi, dataOwnerApi, (_b = (_a = params.encryptedFieldsConfig) === null || _a === void 0 ? void 0 : _a.maintenanceTask) !== null && _b !== void 0 ? _b : EncryptedFieldsConfig.Defaults.maintenanceTask, groupSpecificAuthenticationProvider, fetchImpl);
|
|
183
|
+
const maintenanceTaskApi = new icc_maintenance_task_x_api_1.IccMaintenanceTaskXApi(host, params.headers, cryptoApi, healthcarePartyApi, dataOwnerApi, userApi, authApi, (_b = (_a = params.encryptedFieldsConfig) === null || _a === void 0 ? void 0 : _a.maintenanceTask) !== null && _b !== void 0 ? _b : EncryptedFieldsConfig.Defaults.maintenanceTask, groupSpecificAuthenticationProvider, fetchImpl);
|
|
181
184
|
const icureMaintenanceTaskApi = new icc_icure_maintenance_x_api_1.IccIcureMaintenanceXApi(cryptoApi, maintenanceTaskApi, dataOwnerApi);
|
|
182
|
-
const userApi = new icc_user_x_api_1.IccUserXApi(host, params.headers, groupSpecificAuthenticationProvider, fetchImpl);
|
|
183
185
|
if (newKey && params.createMaintenanceTasksOnNewKey) {
|
|
184
186
|
yield icureMaintenanceTaskApi.createMaintenanceTasksForNewKeypair(yield userApi.getCurrentUser(), newKey.newKeyPair);
|
|
185
187
|
}
|
|
@@ -266,8 +268,8 @@ class IcureApiImpl {
|
|
|
266
268
|
return (_a = this._codeApi) !== null && _a !== void 0 ? _a : (this._codeApi = new icc_code_x_api_1.IccCodeXApi(this.host, this.params.headers, this.groupSpecificAuthenticationProvider, this.fetch));
|
|
267
269
|
}
|
|
268
270
|
get contactApi() {
|
|
269
|
-
var _a;
|
|
270
|
-
return ((_a = this._contactApi) !== null && _a !== void 0 ? _a : (this._contactApi = new icc_contact_x_api_1.IccContactXApi(this.host, this.params.headers, this.cryptoApi, this.dataOwnerApi, this.groupSpecificAuthenticationProvider, this.fetch)));
|
|
271
|
+
var _a, _b, _c;
|
|
272
|
+
return ((_a = this._contactApi) !== null && _a !== void 0 ? _a : (this._contactApi = new icc_contact_x_api_1.IccContactXApi(this.host, this.params.headers, this.cryptoApi, this.dataOwnerApi, this.userApi, this.authApi, this.groupSpecificAuthenticationProvider, this.fetch, (_b = this.params.encryptedFieldsConfig.contact) !== null && _b !== void 0 ? _b : EncryptedFieldsConfig.Defaults.contact, (_c = this.params.encryptedFieldsConfig.service) !== null && _c !== void 0 ? _c : EncryptedFieldsConfig.Defaults.service)));
|
|
271
273
|
}
|
|
272
274
|
get deviceApi() {
|
|
273
275
|
return this.cryptoInitApis.deviceApi;
|
|
@@ -302,7 +304,7 @@ class IcureApiImpl {
|
|
|
302
304
|
}
|
|
303
305
|
get healthcareElementApi() {
|
|
304
306
|
var _a, _b;
|
|
305
|
-
return ((_a = this._healthcareElementApi) !== null && _a !== void 0 ? _a : (this._healthcareElementApi = new icc_helement_x_api_1.IccHelementXApi(this.host, this.params.headers, this.cryptoApi, this.dataOwnerApi, (_b = this.params.encryptedFieldsConfig.healthElement) !== null && _b !== void 0 ? _b : EncryptedFieldsConfig.Defaults.healthElement, this.groupSpecificAuthenticationProvider, this.fetch)));
|
|
307
|
+
return ((_a = this._healthcareElementApi) !== null && _a !== void 0 ? _a : (this._healthcareElementApi = new icc_helement_x_api_1.IccHelementXApi(this.host, this.params.headers, this.cryptoApi, this.dataOwnerApi, this.userApi, this.authApi, (_b = this.params.encryptedFieldsConfig.healthElement) !== null && _b !== void 0 ? _b : EncryptedFieldsConfig.Defaults.healthElement, this.groupSpecificAuthenticationProvider, this.fetch)));
|
|
306
308
|
}
|
|
307
309
|
get healthcarePartyApi() {
|
|
308
310
|
return this.cryptoInitApis.healthcarePartyApi;
|
|
@@ -343,7 +345,7 @@ class IcureApiImpl {
|
|
|
343
345
|
}
|
|
344
346
|
get patientApi() {
|
|
345
347
|
var _a, _b;
|
|
346
|
-
return ((_a = this._patientApi) !== null && _a !== void 0 ? _a : (this._patientApi = new icc_patient_x_api_1.IccPatientXApi(this.host, this.params.headers, this.cryptoApi, this.contactApi, this.formApi, this.healthcareElementApi, this.invoiceApi, this.documentApi, this.healthcarePartyApi, this.classificationApi, this.dataOwnerApi, this.calendarItemApi, (_b = this.params.encryptedFieldsConfig.patient) !== null && _b !== void 0 ? _b : EncryptedFieldsConfig.Defaults.patient, this.groupSpecificAuthenticationProvider, this.fetch)));
|
|
348
|
+
return ((_a = this._patientApi) !== null && _a !== void 0 ? _a : (this._patientApi = new icc_patient_x_api_1.IccPatientXApi(this.host, this.params.headers, this.cryptoApi, this.contactApi, this.formApi, this.healthcareElementApi, this.invoiceApi, this.documentApi, this.healthcarePartyApi, this.classificationApi, this.dataOwnerApi, this.calendarItemApi, this.userApi, this.authApi, (_b = this.params.encryptedFieldsConfig.patient) !== null && _b !== void 0 ? _b : EncryptedFieldsConfig.Defaults.patient, this.groupSpecificAuthenticationProvider, this.fetch)));
|
|
347
349
|
}
|
|
348
350
|
get permissionApi() {
|
|
349
351
|
var _a;
|
|
@@ -424,12 +426,12 @@ const BasicApis = function (host, username, password, crypto = typeof window !==
|
|
|
424
426
|
const authApi = new icc_api_1.IccAuthApi(host, headers, authenticationProvider, fetchImpl);
|
|
425
427
|
const codeApi = new icc_code_x_api_1.IccCodeXApi(host, headers, authenticationProvider, fetchImpl);
|
|
426
428
|
const entityReferenceApi = new icc_api_1.IccEntityrefApi(host, headers, authenticationProvider, fetchImpl);
|
|
427
|
-
const userApi = new icc_user_x_api_1.IccUserXApi(host, headers, authenticationProvider, fetchImpl);
|
|
429
|
+
const userApi = new icc_user_x_api_1.IccUserXApi(host, headers, authenticationProvider, authApi, fetchImpl);
|
|
428
430
|
const permissionApi = new icc_api_1.IccPermissionApi(host, headers, authenticationProvider, fetchImpl);
|
|
429
431
|
const agendaApi = new icc_api_1.IccAgendaApi(host, headers, authenticationProvider, fetchImpl);
|
|
430
432
|
const groupApi = new icc_api_1.IccGroupApi(host, headers, authenticationProvider);
|
|
431
433
|
const insuranceApi = new icc_api_1.IccInsuranceApi(host, headers, authenticationProvider, fetchImpl);
|
|
432
|
-
const healthcarePartyApi = new icc_hcparty_x_api_1.IccHcpartyXApi(host, headers, authenticationProvider, fetchImpl);
|
|
434
|
+
const healthcarePartyApi = new icc_hcparty_x_api_1.IccHcpartyXApi(host, headers, authenticationProvider, authApi, fetchImpl);
|
|
433
435
|
return {
|
|
434
436
|
authApi,
|
|
435
437
|
codeApi,
|