@icure/api 8.8.6 → 8.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/icc-api/api/IccAccesslogApi.d.ts +20 -0
- package/icc-api/api/IccAccesslogApi.js +41 -0
- package/icc-api/api/IccAccesslogApi.js.map +1 -1
- package/icc-api/api/IccAgendaApi.d.ts +20 -0
- package/icc-api/api/IccAgendaApi.js +41 -0
- package/icc-api/api/IccAgendaApi.js.map +1 -1
- package/icc-api/api/IccCalendarItemApi.d.ts +20 -0
- package/icc-api/api/IccCalendarItemApi.js +41 -0
- package/icc-api/api/IccCalendarItemApi.js.map +1 -1
- package/icc-api/api/IccCalendarItemTypeApi.d.ts +20 -0
- package/icc-api/api/IccCalendarItemTypeApi.js +41 -0
- package/icc-api/api/IccCalendarItemTypeApi.js.map +1 -1
- package/icc-api/api/IccCodeApi.d.ts +20 -0
- package/icc-api/api/IccCodeApi.js +41 -0
- package/icc-api/api/IccCodeApi.js.map +1 -1
- package/icc-api/api/IccContactApi.d.ts +20 -0
- package/icc-api/api/IccContactApi.js +41 -0
- package/icc-api/api/IccContactApi.js.map +1 -1
- package/icc-api/api/IccDeviceApi.d.ts +20 -0
- package/icc-api/api/IccDeviceApi.js +41 -0
- package/icc-api/api/IccDeviceApi.js.map +1 -1
- package/icc-api/api/IccDocumentApi.d.ts +20 -0
- package/icc-api/api/IccDocumentApi.js +41 -0
- package/icc-api/api/IccDocumentApi.js.map +1 -1
- package/icc-api/api/IccFormApi.d.ts +20 -0
- package/icc-api/api/IccFormApi.js +41 -0
- package/icc-api/api/IccFormApi.js.map +1 -1
- package/icc-api/api/IccHcpartyApi.d.ts +20 -0
- package/icc-api/api/IccHcpartyApi.js +41 -0
- package/icc-api/api/IccHcpartyApi.js.map +1 -1
- package/icc-api/api/IccHelementApi.d.ts +20 -0
- package/icc-api/api/IccHelementApi.js +41 -0
- package/icc-api/api/IccHelementApi.js.map +1 -1
- package/icc-api/api/IccInsuranceApi.d.ts +20 -0
- package/icc-api/api/IccInsuranceApi.js +41 -0
- package/icc-api/api/IccInsuranceApi.js.map +1 -1
- package/icc-api/api/IccInvoiceApi.d.ts +20 -0
- package/icc-api/api/IccInvoiceApi.js +41 -0
- package/icc-api/api/IccInvoiceApi.js.map +1 -1
- package/icc-api/api/IccMessageApi.d.ts +20 -0
- package/icc-api/api/IccMessageApi.js +41 -0
- package/icc-api/api/IccMessageApi.js.map +1 -1
- package/icc-api/api/IccPatientApi.d.ts +20 -0
- package/icc-api/api/IccPatientApi.js +41 -0
- package/icc-api/api/IccPatientApi.js.map +1 -1
- package/icc-api/api/IccPlaceApi.d.ts +20 -0
- package/icc-api/api/IccPlaceApi.js +41 -0
- package/icc-api/api/IccPlaceApi.js.map +1 -1
- package/icc-api/api/IccReceiptApi.d.ts +20 -0
- package/icc-api/api/IccReceiptApi.js +42 -1
- package/icc-api/api/IccReceiptApi.js.map +1 -1
- package/icc-api/api/IccTopicApi.d.ts +20 -0
- package/icc-api/api/IccTopicApi.js +41 -0
- package/icc-api/api/IccTopicApi.js.map +1 -1
- package/icc-api/api/IccUserApi.d.ts +20 -0
- package/icc-api/api/IccUserApi.js +41 -0
- package/icc-api/api/IccUserApi.js.map +1 -1
- package/icc-api/model/ConflictResolutionStrategy.d.ts +17 -0
- package/icc-api/model/ConflictResolutionStrategy.js +22 -0
- package/icc-api/model/ConflictResolutionStrategy.js.map +1 -0
- package/icc-api/model/MergeResult.d.ts +33 -0
- package/icc-api/model/MergeResult.js +27 -0
- package/icc-api/model/MergeResult.js.map +1 -0
- package/icc-api/model/models.d.ts +2 -0
- package/icc-api/model/models.js +2 -0
- package/icc-api/model/models.js.map +1 -1
- package/icc-x-api/icc-document-x-api.js +12 -8
- package/icc-x-api/icc-document-x-api.js.map +1 -1
- package/icc-x-api/icc-receipt-x-api.js +6 -8
- package/icc-x-api/icc-receipt-x-api.js.map +1 -1
- package/icc-x-api/utils/compression-utils.js +3 -7
- package/icc-x-api/utils/compression-utils.js.map +1 -1
- package/package.json +1 -1
|
@@ -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,kDAAiD;AAEjD,0EAAgG;AAChG,4EAAwE;AAIxE,wEAAoE;AACpE,IAAO,eAAe,GAAG,mCAAgB,CAAC,eAAe,CAAA;AAIzD,mCAA6D;AAC7D,iEAA+F;AAE/F,MAAa,cAAe,SAAQ,uBAAa;IAC/C,IAAI,OAAO;QACT,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,wBAAwB,CAAC,2BAA2B,CAAC,CAAC,EAAE,oCAA4B,CAAC,OAAO,CAAC,CAAC,CAAA;IAC7I,CAAC;IAED,YACE,IAAY,EACZ,OAAkC,EACjB,MAAqB,EACrB,YAA8B,EAC9B,cAAuB,EACxC,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;QAVtC,WAAM,GAAN,MAAM,CAAe;QACrB,iBAAY,GAAZ,YAAY,CAAkB;QAC9B,mBAAc,GAAd,cAAc,CAAS;QASxC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;IAClC,CAAC;IAED;;;;;;;;;;;;;OAaG;IACG,WAAW;6DACf,IAAiB,EACjB,CAAM,EACN,UAII,EAAE;;YAEN,MAAM,OAAO,GAAG,IAAI,MAAM,CAAC,OAAO,iCAC7B,CAAC,CAAC,aAAD,CAAC,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EAAE,SAAS,CAAC,CAAA;IAC7G,CAAC;IAED;;;;;OAKG;IACH,uCAAuC,CAAC,MAAsB,EAAE,SAAmB;QACjF,OAAO,IAAI,CAAC,MAAM,CAAC,0BAA0B,CAAC,iCAAiC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,oCAA4B,CAAC,OAAO,EAAE,EAAE,SAAS,CAAC,CAAA;IACpJ,CAAC;CACF;AAvZD,wCAuZC","sourcesContent":["import { IccReceiptApi } from '../icc-api'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\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 { ShareResult } from './utils/ShareResult'\nimport { EntityShareRequest } from '../icc-api/model/requests/EntityShareRequest'\nimport RequestedPermissionEnum = EntityShareRequest.RequestedPermissionEnum\nimport { SecureDelegation } from '../icc-api/model/SecureDelegation'\nimport AccessLevelEnum = SecureDelegation.AccessLevelEnum\nimport { XHR } from '../icc-api/api/XHR'\nimport { EncryptedEntityXApi } from './basexapi/EncryptedEntityXApi'\nimport { MaintenanceTask } from '../icc-api/model/models'\nimport { EntityWithDelegationTypeName, ua2ab } from './utils'\nimport { compressData, decompressData, getCompressionVersion } from './utils/compression-utils'\n\nexport class IccReceiptXApi extends IccReceiptApi implements EncryptedEntityXApi<models.Receipt> {\n get headers(): Promise<Array<XHR.Header>> {\n return super.headers.then((h) => this.crypto.accessControlKeysHeaders.addAccessControlKeysHeaders(h, EntityWithDelegationTypeName.Receipt))\n }\n\n constructor(\n host: string,\n headers: { [key: string]: string },\n private readonly crypto: IccCryptoXApi,\n private readonly dataOwnerApi: IccDataOwnerXApi,\n private readonly autofillAuthor: boolean,\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.\n * - ignoreAutoDelegations: if true the data won't be shared with the autodelegations of the user, but only with additional delegates\n * - alternateRootDelegation: by default a new entity is created with a root delegation from self to self. In keyless mode this is not possible,\n * and instead the root delegation will be from self to another. You have to specify which delegate will be part of the root delegation.\n * @return a new instance of receipt.\n */\n async newInstance(\n user: models.User,\n r: any,\n options: {\n additionalDelegates?: { [dataOwnerId: string]: AccessLevelEnum }\n ignoreAutoDelegations?: boolean\n alternateRootDelegation?: string\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.primitives.randomUuid(),\n created: r?.created ?? new Date().getTime(),\n modified: r?.modified ?? new Date().getTime(),\n responsible: r?.responsible ?? (this.autofillAuthor ? this.dataOwnerApi.getDataOwnerIdOf(user) : undefined),\n author: r?.author ?? (this.autofillAuthor ? user.id : undefined),\n codes: r?.codes ?? [],\n tags: r?.tags ?? [],\n })\n\n const extraDelegations = {\n ...(options.ignoreAutoDelegations == true\n ? {}\n : Object.fromEntries(\n [...(user.autoDelegations?.all ?? []), ...(user.autoDelegations?.medicalInformation ?? [])].map((d) => [d, AccessLevelEnum.WRITE])\n )),\n ...(options?.additionalDelegates ?? {}),\n }\n return new models.Receipt(\n await this.crypto.xapi\n .entityWithInitialisedEncryptedMetadata(\n receipt,\n EntityWithDelegationTypeName.Receipt,\n undefined,\n undefined,\n true,\n extraDelegations,\n options.alternateRootDelegation\n )\n .then((x) => x.updatedEntity)\n )\n }\n\n /**\n * Creates a new receipt linked to a document and optionally attaches a blob to it.\n * @param user the current user.\n * @param docId the id of the document this receipt refers to.\n * @param refs an array of reference strings to associate with the receipt.\n * @param blobType the type of the blob attachment.\n * @param blob the binary content to attach; if empty (byteLength == 0), no attachment is set.\n * @return the created receipt, with the attachment set if the blob was non-empty.\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.setReceiptAttachmentForBlobType(rcpt.id!, rcpt.rev!, 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, updatedEntity } = await this.crypto.xapi.encryptDataOf(receipt, EntityWithDelegationTypeName.Receipt, attachment, (r) =>\n this.modifyReceipt(r)\n )\n return await this.setReceiptAttachmentForBlobType(receipt.id!, updatedEntity?.rev ?? receipt.rev!, blobType, 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.setReceiptAttachmentForBlobType(receipt.id!, receipt.rev!, blobType, ua2ab(attachment))\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 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 retrieved = await this.getAndTryDecryptReceiptAttachment(receipt, attachmentId, (x) => validator(x))\n if (!retrieved.wasDecrypted) throw new Error(`No valid key found to decrypt data of receipt ${receipt.id}.`)\n return retrieved.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.xapi.tryDecryptDataOf(\n { entity: receipt, type: EntityWithDelegationTypeName.Receipt },\n await this.getReceiptAttachment(receipt.id!, attachmentId),\n async (x) => ((await validator(x)) ? x : undefined)\n )\n }\n\n // --- New data attachment methods (with compression support) ---\n\n /**\n * Compresses, encrypts, and uploads a receipt attachment using the new data attachment endpoint.\n * Compression is attempted automatically; if the compressed result is not smaller, the original data is used.\n * @param receipt a receipt.\n * @param blobType the type of the attachment.\n * @param attachment the raw attachment data.\n * @param deflate if true, compress the attachment before uploading. Reliable decompression of compressed data requires version 26.5 of the API and all users to be using at least version 8.7.0 of the SDK * @return the updated receipt.\n */\n async encryptCompressAndSetReceiptDataAttachment(\n receipt: models.Receipt,\n blobType: string,\n attachment: ArrayBuffer | Uint8Array,\n deflate: boolean = false\n ): Promise<models.Receipt> {\n const realDataSize = ua2ab(attachment).byteLength\n const { data: dataToEncrypt, algorithm: compressionAlgorithm } = deflate\n ? await compressData(attachment)\n : { data: ua2ab(attachment), algorithm: undefined }\n\n const { encryptedData, updatedEntity } = await this.crypto.xapi.encryptDataOf(\n receipt,\n EntityWithDelegationTypeName.Receipt,\n dataToEncrypt,\n (r) => this.modifyReceipt(r)\n )\n return await this.setReceiptDataAttachment(\n receipt.id!,\n blobType,\n updatedEntity?.rev ?? receipt.rev!,\n encryptedData,\n compressionAlgorithm,\n getCompressionVersion(),\n realDataSize\n )\n }\n\n /**\n * Compresses and uploads an unencrypted receipt attachment using the new data attachment endpoint.\n * Compression is attempted automatically; if the compressed result is not smaller, the original data is used.\n * @param receipt a receipt.\n * @param blobType the type of the attachment.\n * @param attachment the raw attachment data.\n * @param deflate if true, compress the attachment before uploading. Reliable decompression of compressed data requires version 26.5 of the API and all users to be using at least version 8.7.0 of the SDK * @return the updated receipt.\n */\n async setClearReceiptDataAttachment(\n receipt: models.Receipt,\n blobType: string,\n attachment: ArrayBuffer | Uint8Array,\n deflate: boolean = false\n ): Promise<models.Receipt> {\n const realDataSize = ua2ab(attachment).byteLength\n const { data: dataToUpload, algorithm: compressionAlgorithm } = deflate\n ? await compressData(attachment)\n : { data: ua2ab(attachment), algorithm: undefined }\n\n return await this.setReceiptDataAttachment(\n receipt.id!,\n blobType,\n receipt.rev!,\n dataToUpload,\n compressionAlgorithm,\n getCompressionVersion(),\n realDataSize\n )\n }\n\n /**\n * Gets a receipt's data attachment by blob type, decrypts it, and decompresses if needed.\n * Throws if decryption fails.\n * @param receipt a receipt.\n * @param blobType the blob type of the attachment to retrieve.\n * @param validator optionally a validator function which checks if the decryption was successful.\n * @return the decrypted (and decompressed) attachment.\n */\n async getAndDecryptReceiptDataAttachment(\n receipt: models.Receipt,\n blobType: string,\n validator: (decrypted: ArrayBuffer) => Promise<boolean> = () => Promise.resolve(true)\n ): Promise<ArrayBuffer> {\n const retrieved = await this.getAndTryDecryptReceiptDataAttachment(receipt, blobType, validator)\n if (!retrieved.wasDecrypted) throw new Error(`No valid key found to decrypt data of receipt ${receipt.id}.`)\n return retrieved.data\n }\n\n /**\n * Gets a receipt's data attachment by blob type, tries to decrypt it, and decompresses if needed.\n * @param receipt a receipt.\n * @param blobType the blob type of the attachment to retrieve.\n * @param validator optionally a validator function which checks if the decryption was successful.\n * @return an object containing:\n * - data: the decrypted (and decompressed) attachment, or the raw data if decryption failed.\n * - wasDecrypted: if the data was successfully decrypted or not.\n */\n async getAndTryDecryptReceiptDataAttachment(\n receipt: models.Receipt,\n blobType: string,\n validator: (decrypted: ArrayBuffer) => Promise<boolean> = () => Promise.resolve(true)\n ): Promise<{ data: ArrayBuffer; wasDecrypted: boolean }> {\n const compressionAlgorithm = receipt.attachmentInfos?.[blobType]?.compressionAlgorithm\n return await this.crypto.xapi.tryDecryptDataOf(\n { entity: receipt, type: EntityWithDelegationTypeName.Receipt },\n await this.getReceiptAttachmentByBlobType(receipt.id!, blobType),\n async (decrypted) => {\n try {\n const data = compressionAlgorithm ? await decompressData(decrypted, compressionAlgorithm) : decrypted\n return (await validator(data)) ? data : undefined\n } catch {\n return undefined\n }\n }\n )\n }\n\n /**\n * @return if the logged data owner has write access to the content of the given receipt\n */\n async hasWriteAccess(receipt: models.Receipt): Promise<boolean> {\n return this.crypto.xapi.hasWriteAccess({ entity: receipt, type: EntityWithDelegationTypeName.Receipt })\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, with read-only or read-write permissions.\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 * - shareSecretIds: specifies which secret ids of the entity should be shared. If not provided all secret ids available to the current user will be shared\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 * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.\n * @return the updated entity\n */\n async shareWith(\n delegateId: string,\n receipt: models.Receipt,\n options: {\n shareSecretIds?: string[]\n requestedPermissions?: RequestedPermissionEnum\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, with read-only or read-write permissions.\n * @param receipt the receipt to share.\n * @param delegates associates the id of data owners which will be granted access to the entity, to the following sharing options:\n * - shareSecretIds: specifies which secret ids of the entity should be shared. If not provided all secret ids available to the current user will be shared\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 * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.\n * @return the updated entity\n */\n async shareWithMany(\n receipt: models.Receipt,\n delegates: {\n [delegateId: string]: {\n shareSecretIds?: string[]\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n }\n }\n ): Promise<models.Receipt> {\n return (await this.tryShareWithMany(receipt, delegates)).updatedEntityOrThrow\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, with read-only or read-write permissions.\n * @param receipt the receipt to share.\n * @param delegates associates the id of data owners which will be granted access to the entity, to the following sharing options:\n * - shareSecretIds: specifies which secret ids of the entity should be shared. If not provided all secret ids available to the current user will be shared\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 * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.\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 tryShareWithMany(\n receipt: models.Receipt,\n delegates: {\n [delegateId: string]: {\n shareSecretIds?: string[]\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n }\n }\n ): Promise<ShareResult<models.Receipt>> {\n // All entities should have an encryption key.\n const entityWithEncryptionKey = await this.crypto.xapi.ensureEncryptionKeysInitialised(receipt, EntityWithDelegationTypeName.Receipt)\n const updatedEntity = entityWithEncryptionKey ? await this.modifyReceipt(entityWithEncryptionKey) : receipt\n return this.crypto.xapi.simpleShareOrUpdateEncryptedEntityMetadata(\n {\n entity: updatedEntity,\n type: EntityWithDelegationTypeName.Receipt,\n },\n Object.fromEntries(\n Object.entries(delegates).map(([delegateId, options]) => [\n delegateId,\n {\n requestedPermissions: options.requestedPermissions,\n shareEncryptionKeys: options.shareEncryptionKey,\n shareOwningEntityIds: ShareMetadataBehaviour.NEVER,\n shareSecretIds: options.shareSecretIds,\n },\n ])\n ),\n (x) => this.bulkShareReceipt(x)\n )\n }\n\n /**\n * Retrieves the data owners that have access to the given receipt, along with their access levels.\n * @param entity the receipt.\n * @return an object containing a map of data owner ids to their access levels, and a flag indicating if there are unknown anonymous data owners.\n */\n getDataOwnersWithAccessTo(\n entity: models.Receipt\n ): Promise<{ permissionsByDataOwnerId: { [p: string]: AccessLevelEnum }; hasUnknownAnonymousDataOwners: boolean }> {\n return this.crypto.delegationsDeAnonymization.getDataOwnersWithAccessTo({ entity, type: EntityWithDelegationTypeName.Receipt })\n }\n\n /**\n * Retrieves the encryption keys of the given receipt.\n * @param entity the receipt.\n * @return the encryption key ids.\n */\n getEncryptionKeysOf(entity: models.Receipt): Promise<string[]> {\n return this.crypto.xapi.encryptionKeysOf({ entity, type: EntityWithDelegationTypeName.Receipt }, undefined)\n }\n\n /**\n * Creates or updates de-anonymization metadata for the given receipt, allowing the specified delegates to\n * identify the data owners that have access to it.\n * @param entity the receipt.\n * @param delegates the data owner ids for which to create de-anonymization metadata.\n */\n createDelegationDeAnonymizationMetadata(entity: models.Receipt, delegates: string[]): Promise<void> {\n return this.crypto.delegationsDeAnonymization.createOrUpdateDeAnonymizationInfo({ entity, type: EntityWithDelegationTypeName.Receipt }, delegates)\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"icc-receipt-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-receipt-x-api.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wCAA0C;AAE1C,kDAAiD;AAEjD,0EAAgG;AAChG,4EAAwE;AAIxE,wEAAoE;AACpE,IAAO,eAAe,GAAG,mCAAgB,CAAC,eAAe,CAAA;AAIzD,mCAA6D;AAC7D,iEAA+F;AAE/F,MAAa,cAAe,SAAQ,uBAAa;IAC/C,IAAI,OAAO;QACT,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,wBAAwB,CAAC,2BAA2B,CAAC,CAAC,EAAE,oCAA4B,CAAC,OAAO,CAAC,CAAC,CAAA;IAC7I,CAAC;IAED,YACE,IAAY,EACZ,OAAkC,EACjB,MAAqB,EACrB,YAA8B,EAC9B,cAAuB,EACxC,yBAAiD,IAAI,iDAAwB,EAAE,EAC/E,YAA2E,OAAO,MAAM,KAAK,WAAW;QACtG,CAAC,CAAC,MAAM,CAAC,KAAK;QACd,CAAC,CAAC,OAAO,IAAI,KAAK,WAA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iBACvC;aACF,CAAC,CACH,EACD,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAChC,CAAA;QACH,CAAC;KAAA;IAED;;;;OAIG;IACH,yBAAyB,CACvB,MAAsB;QAEtB,OAAO,IAAI,CAAC,MAAM,CAAC,0BAA0B,CAAC,yBAAyB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,oCAA4B,CAAC,OAAO,EAAE,CAAC,CAAA;IACjI,CAAC;IAED;;;;OAIG;IACH,mBAAmB,CAAC,MAAsB;QACxC,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,oCAA4B,CAAC,OAAO,EAAE,EAAE,SAAS,CAAC,CAAA;IAC7G,CAAC;IAED;;;;;OAKG;IACH,uCAAuC,CAAC,MAAsB,EAAE,SAAmB;QACjF,OAAO,IAAI,CAAC,MAAM,CAAC,0BAA0B,CAAC,iCAAiC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,oCAA4B,CAAC,OAAO,EAAE,EAAE,SAAS,CAAC,CAAA;IACpJ,CAAC;CACF;AAlZD,wCAkZC","sourcesContent":["import { IccReceiptApi } from '../icc-api'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\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 { ShareResult } from './utils/ShareResult'\nimport { EntityShareRequest } from '../icc-api/model/requests/EntityShareRequest'\nimport RequestedPermissionEnum = EntityShareRequest.RequestedPermissionEnum\nimport { SecureDelegation } from '../icc-api/model/SecureDelegation'\nimport AccessLevelEnum = SecureDelegation.AccessLevelEnum\nimport { XHR } from '../icc-api/api/XHR'\nimport { EncryptedEntityXApi } from './basexapi/EncryptedEntityXApi'\nimport { MaintenanceTask } from '../icc-api/model/models'\nimport { EntityWithDelegationTypeName, ua2ab } from './utils'\nimport { compressData, decompressData, getCompressionVersion } from './utils/compression-utils'\n\nexport class IccReceiptXApi extends IccReceiptApi implements EncryptedEntityXApi<models.Receipt> {\n get headers(): Promise<Array<XHR.Header>> {\n return super.headers.then((h) => this.crypto.accessControlKeysHeaders.addAccessControlKeysHeaders(h, EntityWithDelegationTypeName.Receipt))\n }\n\n constructor(\n host: string,\n headers: { [key: string]: string },\n private readonly crypto: IccCryptoXApi,\n private readonly dataOwnerApi: IccDataOwnerXApi,\n private readonly autofillAuthor: boolean,\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.\n * - ignoreAutoDelegations: if true the data won't be shared with the autodelegations of the user, but only with additional delegates\n * - alternateRootDelegation: by default a new entity is created with a root delegation from self to self. In keyless mode this is not possible,\n * and instead the root delegation will be from self to another. You have to specify which delegate will be part of the root delegation.\n * @return a new instance of receipt.\n */\n async newInstance(\n user: models.User,\n r: any,\n options: {\n additionalDelegates?: { [dataOwnerId: string]: AccessLevelEnum }\n ignoreAutoDelegations?: boolean\n alternateRootDelegation?: string\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.primitives.randomUuid(),\n created: r?.created ?? new Date().getTime(),\n modified: r?.modified ?? new Date().getTime(),\n responsible: r?.responsible ?? (this.autofillAuthor ? this.dataOwnerApi.getDataOwnerIdOf(user) : undefined),\n author: r?.author ?? (this.autofillAuthor ? user.id : undefined),\n codes: r?.codes ?? [],\n tags: r?.tags ?? [],\n })\n\n const extraDelegations = {\n ...(options.ignoreAutoDelegations == true\n ? {}\n : Object.fromEntries(\n [...(user.autoDelegations?.all ?? []), ...(user.autoDelegations?.medicalInformation ?? [])].map((d) => [d, AccessLevelEnum.WRITE])\n )),\n ...(options?.additionalDelegates ?? {}),\n }\n return new models.Receipt(\n await this.crypto.xapi\n .entityWithInitialisedEncryptedMetadata(\n receipt,\n EntityWithDelegationTypeName.Receipt,\n undefined,\n undefined,\n true,\n extraDelegations,\n options.alternateRootDelegation\n )\n .then((x) => x.updatedEntity)\n )\n }\n\n /**\n * Creates a new receipt linked to a document and optionally attaches a blob to it.\n * @param user the current user.\n * @param docId the id of the document this receipt refers to.\n * @param refs an array of reference strings to associate with the receipt.\n * @param blobType the type of the blob attachment.\n * @param blob the binary content to attach; if empty (byteLength == 0), no attachment is set.\n * @return the created receipt, with the attachment set if the blob was non-empty.\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.setReceiptAttachmentForBlobType(rcpt.id!, rcpt.rev!, 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, updatedEntity } = await this.crypto.xapi.encryptDataOf(receipt, EntityWithDelegationTypeName.Receipt, attachment, (r) =>\n this.modifyReceipt(r)\n )\n return await this.setReceiptAttachmentForBlobType(receipt.id!, updatedEntity?.rev ?? receipt.rev!, blobType, 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.setReceiptAttachmentForBlobType(receipt.id!, receipt.rev!, blobType, ua2ab(attachment))\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 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 retrieved = await this.getAndTryDecryptReceiptAttachment(receipt, attachmentId, (x) => validator(x))\n if (!retrieved.wasDecrypted) throw new Error(`No valid key found to decrypt data of receipt ${receipt.id}.`)\n return retrieved.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.xapi.tryDecryptDataOf(\n { entity: receipt, type: EntityWithDelegationTypeName.Receipt },\n await this.getReceiptAttachment(receipt.id!, attachmentId),\n async (x) => ((await validator(x)) ? x : undefined)\n )\n }\n\n // --- New data attachment methods (with compression support) ---\n\n /**\n * Compresses, encrypts, and uploads a receipt attachment using the new data attachment endpoint.\n * Compression is attempted automatically; if the compressed result is not smaller, the original data is used.\n * @param receipt a receipt.\n * @param blobType the type of the attachment.\n * @param attachment the raw attachment data.\n * @param deflate if true, compress the attachment before uploading. Reliable decompression of compressed data requires version 26.5 of the API and all users to be using at least version 8.7.0 of the SDK * @return the updated receipt.\n */\n async encryptCompressAndSetReceiptDataAttachment(\n receipt: models.Receipt,\n blobType: string,\n attachment: ArrayBuffer | Uint8Array,\n deflate: boolean = false\n ): Promise<models.Receipt> {\n const raw = ua2ab(attachment)\n const realDataSize = raw.byteLength\n const { data: dataToEncrypt, algorithm: compressionAlgorithm } = deflate ? await compressData(attachment) : { data: raw, algorithm: undefined }\n\n const { encryptedData, updatedEntity } = await this.crypto.xapi.encryptDataOf(receipt, EntityWithDelegationTypeName.Receipt, dataToEncrypt, (r) =>\n this.modifyReceipt(r)\n )\n return await this.setReceiptDataAttachment(\n receipt.id!,\n blobType,\n updatedEntity?.rev ?? receipt.rev!,\n encryptedData,\n compressionAlgorithm,\n getCompressionVersion(),\n realDataSize\n )\n }\n\n /**\n * Compresses and uploads an unencrypted receipt attachment using the new data attachment endpoint.\n * Compression is attempted automatically; if the compressed result is not smaller, the original data is used.\n * @param receipt a receipt.\n * @param blobType the type of the attachment.\n * @param attachment the raw attachment data.\n * @param deflate if true, compress the attachment before uploading. Reliable decompression of compressed data requires version 26.5 of the API and all users to be using at least version 8.7.0 of the SDK * @return the updated receipt.\n */\n async setClearReceiptDataAttachment(\n receipt: models.Receipt,\n blobType: string,\n attachment: ArrayBuffer | Uint8Array,\n deflate: boolean = false\n ): Promise<models.Receipt> {\n const raw = ua2ab(attachment)\n const realDataSize = raw.byteLength\n const { data: dataToUpload, algorithm: compressionAlgorithm } = deflate ? await compressData(attachment) : { data: raw, algorithm: undefined }\n\n return await this.setReceiptDataAttachment(\n receipt.id!,\n blobType,\n receipt.rev!,\n dataToUpload,\n compressionAlgorithm,\n getCompressionVersion(),\n realDataSize\n )\n }\n\n /**\n * Gets a receipt's data attachment by blob type, decrypts it, and decompresses if needed.\n * Throws if decryption fails.\n * @param receipt a receipt.\n * @param blobType the blob type of the attachment to retrieve.\n * @param validator optionally a validator function which checks if the decryption was successful.\n * @return the decrypted (and decompressed) attachment.\n */\n async getAndDecryptReceiptDataAttachment(\n receipt: models.Receipt,\n blobType: string,\n validator: (decrypted: ArrayBuffer) => Promise<boolean> = () => Promise.resolve(true)\n ): Promise<ArrayBuffer> {\n const retrieved = await this.getAndTryDecryptReceiptDataAttachment(receipt, blobType, validator)\n if (!retrieved.wasDecrypted) throw new Error(`No valid key found to decrypt data of receipt ${receipt.id}.`)\n return retrieved.data\n }\n\n /**\n * Gets a receipt's data attachment by blob type, tries to decrypt it, and decompresses if needed.\n * @param receipt a receipt.\n * @param blobType the blob type of the attachment to retrieve.\n * @param validator optionally a validator function which checks if the decryption was successful.\n * @return an object containing:\n * - data: the decrypted (and decompressed) attachment, or the raw data if decryption failed.\n * - wasDecrypted: if the data was successfully decrypted or not.\n */\n async getAndTryDecryptReceiptDataAttachment(\n receipt: models.Receipt,\n blobType: string,\n validator: (decrypted: ArrayBuffer) => Promise<boolean> = () => Promise.resolve(true)\n ): Promise<{ data: ArrayBuffer; wasDecrypted: boolean }> {\n const compressionAlgorithm = receipt.attachmentInfos?.[blobType]?.compressionAlgorithm\n return await this.crypto.xapi.tryDecryptDataOf(\n { entity: receipt, type: EntityWithDelegationTypeName.Receipt },\n await this.getReceiptAttachmentByBlobType(receipt.id!, blobType),\n async (decrypted) => {\n try {\n const data = compressionAlgorithm ? await decompressData(decrypted, compressionAlgorithm) : decrypted\n return (await validator(data)) ? data : undefined\n } catch {\n return undefined\n }\n }\n )\n }\n\n /**\n * @return if the logged data owner has write access to the content of the given receipt\n */\n async hasWriteAccess(receipt: models.Receipt): Promise<boolean> {\n return this.crypto.xapi.hasWriteAccess({ entity: receipt, type: EntityWithDelegationTypeName.Receipt })\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, with read-only or read-write permissions.\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 * - shareSecretIds: specifies which secret ids of the entity should be shared. If not provided all secret ids available to the current user will be shared\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 * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.\n * @return the updated entity\n */\n async shareWith(\n delegateId: string,\n receipt: models.Receipt,\n options: {\n shareSecretIds?: string[]\n requestedPermissions?: RequestedPermissionEnum\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, with read-only or read-write permissions.\n * @param receipt the receipt to share.\n * @param delegates associates the id of data owners which will be granted access to the entity, to the following sharing options:\n * - shareSecretIds: specifies which secret ids of the entity should be shared. If not provided all secret ids available to the current user will be shared\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 * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.\n * @return the updated entity\n */\n async shareWithMany(\n receipt: models.Receipt,\n delegates: {\n [delegateId: string]: {\n shareSecretIds?: string[]\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n }\n }\n ): Promise<models.Receipt> {\n return (await this.tryShareWithMany(receipt, delegates)).updatedEntityOrThrow\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, with read-only or read-write permissions.\n * @param receipt the receipt to share.\n * @param delegates associates the id of data owners which will be granted access to the entity, to the following sharing options:\n * - shareSecretIds: specifies which secret ids of the entity should be shared. If not provided all secret ids available to the current user will be shared\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 * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.\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 tryShareWithMany(\n receipt: models.Receipt,\n delegates: {\n [delegateId: string]: {\n shareSecretIds?: string[]\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n }\n }\n ): Promise<ShareResult<models.Receipt>> {\n // All entities should have an encryption key.\n const entityWithEncryptionKey = await this.crypto.xapi.ensureEncryptionKeysInitialised(receipt, EntityWithDelegationTypeName.Receipt)\n const updatedEntity = entityWithEncryptionKey ? await this.modifyReceipt(entityWithEncryptionKey) : receipt\n return this.crypto.xapi.simpleShareOrUpdateEncryptedEntityMetadata(\n {\n entity: updatedEntity,\n type: EntityWithDelegationTypeName.Receipt,\n },\n Object.fromEntries(\n Object.entries(delegates).map(([delegateId, options]) => [\n delegateId,\n {\n requestedPermissions: options.requestedPermissions,\n shareEncryptionKeys: options.shareEncryptionKey,\n shareOwningEntityIds: ShareMetadataBehaviour.NEVER,\n shareSecretIds: options.shareSecretIds,\n },\n ])\n ),\n (x) => this.bulkShareReceipt(x)\n )\n }\n\n /**\n * Retrieves the data owners that have access to the given receipt, along with their access levels.\n * @param entity the receipt.\n * @return an object containing a map of data owner ids to their access levels, and a flag indicating if there are unknown anonymous data owners.\n */\n getDataOwnersWithAccessTo(\n entity: models.Receipt\n ): Promise<{ permissionsByDataOwnerId: { [p: string]: AccessLevelEnum }; hasUnknownAnonymousDataOwners: boolean }> {\n return this.crypto.delegationsDeAnonymization.getDataOwnersWithAccessTo({ entity, type: EntityWithDelegationTypeName.Receipt })\n }\n\n /**\n * Retrieves the encryption keys of the given receipt.\n * @param entity the receipt.\n * @return the encryption key ids.\n */\n getEncryptionKeysOf(entity: models.Receipt): Promise<string[]> {\n return this.crypto.xapi.encryptionKeysOf({ entity, type: EntityWithDelegationTypeName.Receipt }, undefined)\n }\n\n /**\n * Creates or updates de-anonymization metadata for the given receipt, allowing the specified delegates to\n * identify the data owners that have access to it.\n * @param entity the receipt.\n * @param delegates the data owner ids for which to create de-anonymization metadata.\n */\n createDelegationDeAnonymizationMetadata(entity: models.Receipt, delegates: string[]): Promise<void> {\n return this.crypto.delegationsDeAnonymization.createOrUpdateDeAnonymizationInfo({ entity, type: EntityWithDelegationTypeName.Receipt }, delegates)\n }\n}\n"]}
|
|
@@ -13,6 +13,7 @@ exports.getCompressionVersion = getCompressionVersion;
|
|
|
13
13
|
exports.compressData = compressData;
|
|
14
14
|
exports.decompressData = decompressData;
|
|
15
15
|
const lzma_wasm_1 = require("./lzma-wasm");
|
|
16
|
+
const binary_utils_1 = require("./binary-utils");
|
|
16
17
|
const COMPRESSION_VERSION = '1';
|
|
17
18
|
const MINIMUM_SIZE_FOR_COMPRESSION = 64;
|
|
18
19
|
/** UTIs for formats that are already compressed and won't benefit from additional compression. */
|
|
@@ -68,7 +69,7 @@ function getCompressionVersion() {
|
|
|
68
69
|
*/
|
|
69
70
|
function compressData(data, utis) {
|
|
70
71
|
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
-
const raw =
|
|
72
|
+
const raw = (0, binary_utils_1.ua2ab)(data);
|
|
72
73
|
if ((utis === null || utis === void 0 ? void 0 : utis.some((uti) => ALREADY_COMPRESSED_UTIS.has(uti))) || raw.byteLength < MINIMUM_SIZE_FOR_COMPRESSION) {
|
|
73
74
|
return { data: raw, algorithm: undefined };
|
|
74
75
|
}
|
|
@@ -90,7 +91,7 @@ function compressData(data, utis) {
|
|
|
90
91
|
function decompressData(data, algorithm) {
|
|
91
92
|
return __awaiter(this, void 0, void 0, function* () {
|
|
92
93
|
if (!algorithm) {
|
|
93
|
-
return
|
|
94
|
+
return (0, binary_utils_1.ua2ab)(data);
|
|
94
95
|
}
|
|
95
96
|
if (algorithm === 'lzma2') {
|
|
96
97
|
return (0, lzma_wasm_1.lzmaWasmDecompress)(data);
|
|
@@ -98,9 +99,4 @@ function decompressData(data, algorithm) {
|
|
|
98
99
|
throw new Error(`Unsupported compression algorithm: ${algorithm}`);
|
|
99
100
|
});
|
|
100
101
|
}
|
|
101
|
-
function toArrayBuffer(data) {
|
|
102
|
-
if (data instanceof ArrayBuffer)
|
|
103
|
-
return data;
|
|
104
|
-
return new Uint8Array(data).buffer;
|
|
105
|
-
}
|
|
106
102
|
//# sourceMappingURL=compression-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compression-utils.js","sourceRoot":"","sources":["../../../icc-x-api/utils/compression-utils.ts"],"names":[],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"compression-utils.js","sourceRoot":"","sources":["../../../icc-x-api/utils/compression-utils.ts"],"names":[],"mappings":";;;;;;;;;;;AAmDA,sDAEC;AAWD,oCAYC;AAUD,wCAQC;AA9FD,2C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AAU,EAAE,CAAC;YAC3C,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,CAAA;QACjD,CAAC;QACD,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,CAAA;IAC5C,CAAC;CAAA;AAED;;;;;;;GAOG;AACH,SAAsB,cAAc,CAAC,IAA8B,EAAE,SAA6B;;QAChG,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,OAAO,IAAA,oBAAK,EAAC,IAAI,CAAC,CAAA;QACpB,CAAC;QACD,IAAI,SAAS,KAAK,OAAO,EAAE,CAAC;YAC1B,OAAO,IAAA,8BAAkB,EAAC,IAAI,CAAC,CAAA;QACjC,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,sCAAsC,SAAS,EAAE,CAAC,CAAA;IACpE,CAAC;CAAA","sourcesContent":["import { lzmaWasmCompress, lzmaWasmDecompress } from './lzma-wasm'\nimport { ua2ab } from './binary-utils'\n\nconst COMPRESSION_VERSION = '1'\nconst MINIMUM_SIZE_FOR_COMPRESSION = 64\n\n/** UTIs for formats that are already compressed and won't benefit from additional compression. */\nconst ALREADY_COMPRESSED_UTIS = new Set([\n // Images\n 'public.jpeg',\n 'public.jpeg2000',\n 'public.png',\n 'com.compuserve.gif',\n 'com.microsoft.bmp', // low entropy but compression marginal vs overhead\n // Video\n 'public.mpeg',\n 'public.mpeg4',\n 'public.mpegts',\n 'com.apple.quicktime-movie',\n // Audio\n 'public.mpeg4-audio',\n 'public.mp3',\n // Archives / compressed formats\n 'com.pkware.zip-archive',\n 'org.gnu.gnu-zip-archive',\n 'org.bzip.bzip2-archive',\n 'com.rarlab.rar-archive',\n 'com.allume.stuffit-archive',\n 'org.7-zip.7-zip-archive',\n 'public.tar-archive',\n 'org.gnu.gnu-tar-archive',\n // Legacy UTI variants (pre-v1.0.117 camelCase format)\n 'com.pkware.zipArchive',\n 'org.gnu.gnuZipArchive',\n 'org.bzip.bzip2Archive',\n 'com.rarlab.rarArchive',\n 'com.allume.stuffitArchive',\n 'org.gnu.gnuTarArchive',\n 'public.mpeg4Audio',\n 'com.apple.quicktimeMovie',\n])\n\nexport interface CompressionResult {\n data: ArrayBuffer\n algorithm: string | undefined\n}\n\n/**\n * Returns the current compression algorithms version string.\n * This version is bumped whenever the set of tried algorithms changes.\n */\nexport function getCompressionVersion(): string {\n return COMPRESSION_VERSION\n}\n\n/**\n * Attempts to compress the given data using available compression algorithms, picking the best result.\n * If any of the provided UTIs indicates the data is already in a compressed format (jpeg, png, zip, ...),\n * compression is skipped entirely.\n *\n * @param data the raw data to compress.\n * @param utis optional UTIs describing the data format; used to skip compression for already-compressed formats.\n * @returns the (possibly compressed) data and the algorithm used, or undefined if no compression was applied.\n */\nexport async function compressData(data: ArrayBuffer | Uint8Array, utis?: string[]): Promise<CompressionResult> {\n const raw = ua2ab(data)\n\n if (utis?.some((uti) => ALREADY_COMPRESSED_UTIS.has(uti)) || raw.byteLength < MINIMUM_SIZE_FOR_COMPRESSION) {\n return { data: raw, algorithm: undefined }\n }\n\n const compressed = await lzmaWasmCompress(data)\n if (compressed.byteLength < raw.byteLength) {\n return { data: compressed, algorithm: 'lzma2' }\n }\n return { data: raw, algorithm: undefined }\n}\n\n/**\n * Decompresses data that was compressed using one of the supported algorithms.\n *\n * @param data the compressed data.\n * @param algorithm the compression algorithm that was used (e.g. 'lzma'). If undefined, returns the data as-is.\n * @returns the decompressed data.\n * @throws if the algorithm is not supported or decompression fails.\n */\nexport async function decompressData(data: ArrayBuffer | Uint8Array, algorithm: string | undefined): Promise<ArrayBuffer> {\n if (!algorithm) {\n return ua2ab(data)\n }\n if (algorithm === 'lzma2') {\n return lzmaWasmDecompress(data)\n }\n throw new Error(`Unsupported compression algorithm: ${algorithm}`)\n}\n"]}
|