import { IccAccesslogApi } from '../icc-api'; import { IccCryptoXApi } from './icc-crypto-x-api'; import * as models from '../icc-api/model/models'; import { AccessLog, ListOfIds, PaginatedListAccessLog } from '../icc-api/model/models'; import { IccDataOwnerXApi } from './icc-data-owner-x-api'; import { AuthenticationProvider } from './auth/AuthenticationProvider'; import { SecureDelegation } from '../icc-api/model/SecureDelegation'; import { ShareMetadataBehaviour } from './crypto/ShareMetadataBehaviour'; import { EntityShareRequest } from '../icc-api/model/requests/EntityShareRequest'; import { ShareResult } from './utils/ShareResult'; import { XHR } from '../icc-api/api/XHR'; import { EncryptedEntityXApi } from './basexapi/EncryptedEntityXApi'; import { SecretIdUseOption } from './crypto/SecretIdUseOption'; import AccessLevelEnum = SecureDelegation.AccessLevelEnum; import RequestedPermissionEnum = EntityShareRequest.RequestedPermissionEnum; export declare class IccAccesslogXApi extends IccAccesslogApi implements EncryptedEntityXApi { private readonly autofillAuthor; private readonly encryptedFields; crypto: IccCryptoXApi; dataOwnerApi: IccDataOwnerXApi; get headers(): Promise>; constructor(host: string, headers: { [key: string]: string; }, crypto: IccCryptoXApi, dataOwnerApi: IccDataOwnerXApi, autofillAuthor: boolean, cryptedKeys?: string[], authenticationProvider?: AuthenticationProvider, fetchImpl?: (input: RequestInfo, init?: RequestInit) => Promise); /** * Creates a new instance of access log with initialised encryption metadata (not in the database). * @param user the current user. * @param patient the patient this access log refers to. * @param h initialised data for the access log. Metadata such as id, creation data, etc. will be automatically initialised, but you can specify * other kinds of data or overwrite generated metadata with this. You can't specify encryption metadata. * @param options optional parameters: * - additionalDelegates: delegates which will have access to the entity in addition to the current data owner and delegates from the * 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 * auto-delegations, in such case the access level specified here will be used. * - sfkOption: specifies which sfk of the owning entity to use. * - ignoreAutoDelegations: if true the data won't be shared with the autodelegations of the user, but only with additional delegates * - alternateRootDelegation: by default a new entity is created with a root delegation from self to self. In keyless mode this is not possible, * and instead the root delegation will be from self to another. You have to specify which delegate will be part of the root delegation. * @return a new instance of access log. */ newInstance(user: models.User, patient: models.Patient, h: any, options?: { additionalDelegates?: { [dataOwnerId: string]: AccessLevelEnum; }; sfkOption?: SecretIdUseOption; ignoreAutoDelegations?: boolean; alternateRootDelegation?: string; }): Promise; /** * Creates a new instance of access log with initialised encryption metadata (not in the database). * @param user the current user. * @param h initialised data for the access log. Metadata such as id, creation data, etc. will be automatically initialised, but you can specify * other kinds of data or overwrite generated metadata with this. You can't specify encryption metadata. * @param options optional parameters: * - additionalDelegates: delegates which will have access to the entity in addition to the current data owner and delegates from the * 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 * auto-delegations, in such case the access level specified here will be used. * - ignoreAutoDelegations: if true the data won't be shared with the autodelegations of the user, but only with additional delegates * - alternateRootDelegation: by default a new entity is created with a root delegation from self to self. In keyless mode this is not possible, * and instead the root delegation will be from self to another. You have to specify which delegate will be part of the root delegation. * @return a new instance of access log. */ newInstanceNoPatient(user: models.User, h: any, options?: { additionalDelegates?: { [dataOwnerId: string]: AccessLevelEnum; }; ignoreAutoDelegations?: boolean; alternateRootDelegation?: string; }): Promise; /** * 1. Check whether there is a delegation with 'hcpartyId' or not. * 2. 'fetchHcParty[hcpartyId][1]': is encrypted AES exchange key by RSA public key of him. * 3. Obtain the AES exchange key, by decrypting the previous step value with hcparty private key * 3.1. KeyPair should be fetch from cache (in jwk) * 3.2. if it doesn't exist in the cache, it has to be loaded from Browser Local store, and then import it to WebCrypto * 4. Obtain the array of delegations which are delegated to his ID (hcpartyId) in this patient * 5. Decrypt and collect all keys (secretForeignKeys) within delegations of previous step (with obtained AES key of step 4) * 6. Do the REST call to get all access logs with (allSecretForeignKeysDelimitedByComma, hcpartyId) * * After these painful steps, you have the access logs of the patient. * * @deprecated use {@link findIdsBy} instead * @param hcpartyId * @param patient (Promise) * @param usingPost */ findBy(hcpartyId: string, patient: models.Patient, usingPost?: boolean): Promise; /** * Same as `findBy` but it will only return the ids of the access logs. It can also filter the access logs where AccessLog.date is between * startDate and endDate in ascending or descending order by that field. (default: ascending). */ findIdsBy(hcpartyId: string, patient: models.Patient, startDate?: number, endDate?: number, descending?: boolean): Promise; /** * @deprecated use {@link findAccessLogIdsByDataOwnerPatientDate} instead */ findByHCPartyPatientSecretFKeys(hcPartyId: string, secretFKeys: string): Promise; /** * @deprecated use {@link findAccessLogIdsByDataOwnerPatientDate} instead */ findByHCPartyPatientSecretFKeysArray(hcPartyId: string, secretFKeys: string[]): Promise | any>; /** * Decrypts a list of access logs using the current data owner's keys. * @param hcpId the id of the healthcare party performing the decryption. * @param accessLogs the access logs to decrypt. * @return the decrypted access logs. */ decrypt(hcpId: string, accessLogs: Array): Promise>; /** * Encrypts the encrypted fields of a list of access logs. * @param user the current user, used to determine the data owner for encryption. * @param accessLogs the access logs to encrypt. * @return the encrypted access logs. */ encrypt(user: models.User, accessLogs: Array): Promise>; private encryptAs; /** * @throws always. Use {@link createAccessLogWithUser} instead. */ createAccessLog(body?: models.AccessLog): never; /** * Creates an access log after encrypting its content. * @param user the current user, used for encryption. * @param body the access log to create. * @return the created and decrypted access log. */ createAccessLogWithUser(user: models.User, body?: models.AccessLog): Promise; /** * @throws always. Use {@link getAccessLogWithUser} instead. */ getAccessLog(accessLogId: string): never; /** * Retrieves an access log by id and decrypts it. * @param user the current user, used for decryption. * @param accessLogId the id of the access log to retrieve. * @return the decrypted access log. */ getAccessLogWithUser(user: models.User, accessLogId: string): Promise; /** * @throws always. Use {@link getAccessLogsWithUser} instead. */ getAccessLogs(ids: ListOfIds): Promise; /** * Retrieves multiple access logs by their ids and decrypts them. * @param user the current user, used for decryption. * @param ids the list of access log ids to retrieve. * @return the decrypted access logs. */ getAccessLogsWithUser(user: models.User, ids: ListOfIds): Promise; /** * @throws always. Use {@link listAccessLogsWithUser} instead. */ listAccessLogs(fromEpoch?: number, toEpoch?: number, startKey?: number, startDocumentId?: string, limit?: number): never; /** * Lists access logs within a date range and decrypts them. * @param user the current user, used for decryption. * @param fromEpoch the start of the date range (epoch in ms). * @param toEpoch the end of the date range (epoch in ms). * @param startKey the pagination start key. * @param startDocumentId the pagination start document id. * @param limit the maximum number of results to return. * @param descending if true, results are returned in descending order. * @return a paginated list of decrypted access logs. */ listAccessLogsWithUser(user: models.User, fromEpoch?: number, toEpoch?: number, startKey?: number, startDocumentId?: string, limit?: number, descending?: boolean): Promise; /** * @throws always. Use {@link modifyAccessLogWithUser} instead. */ modifyAccessLog(body?: models.AccessLog): never; /** * Modifies an access log after encrypting its content. * @param user the current user, used for encryption/decryption. * @param body the access log with updated fields. * @return the modified and decrypted access log, or null if body was not provided. */ modifyAccessLogWithUser(user: models.User, body?: models.AccessLog): Promise; private modifyAs; /** * @throws always. Use {@link findByUserAfterDateWithUser} instead. */ findByUserAfterDate(userId: string, accessType?: string, startDate?: number, startKey?: string, startDocumentId?: string, limit?: number, descending?: boolean): never; /** * Finds access logs by user id after a given date and decrypts them. * @param user the current user, used for decryption. * @param userId the id of the user whose access logs to find. * @param accessType optional access type filter. * @param startDate optional start date filter (epoch in ms). * @param startKey the pagination start key. * @param startDocumentId the pagination start document id. * @param limit the maximum number of results to return. * @param descending if true, results are returned in descending order. * @return a paginated list of decrypted access logs. */ findByUserAfterDateWithUser(user: models.User, userId: string, accessType?: string, startDate?: number, startKey?: string, startDocumentId?: string, limit?: number, descending?: boolean): Promise; /** * @param accessLog an access log * @return the id of the patient that the access log refers to, retrieved from the encrypted metadata (not from the decrypted entity body). Normally * there should only be one element in the returned array, but in case of entity merges there could be multiple values. */ decryptPatientIdOf(accessLog: AccessLog): Promise; /** * @return if the logged data owner has write access to the content of the given access log */ hasWriteAccess(accessLog: AccessLog): Promise; /** * Share an existing access log with other data owners, allowing them to access the non-encrypted data of the access log and optionally also the * encrypted content, with read-only or read-write permissions. * @param delegateId the id of the data owner which will be granted access to the access log. * @param accessLog the access log to share. * @param options optional parameters to customize the sharing behaviour: * - 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 * - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted * content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). * - sharePatientId: specifies if the id of the patient that this access log refers to should be shared with the delegate. Normally this would * be the same as objectId, but it is encrypted separately from it allowing you to give access to the patient id without giving access to the other * encrypted data of the access log (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}. * @return the updated entity */ shareWith(delegateId: string, accessLog: AccessLog, options?: { shareSecretIds?: string[]; requestedPermissions?: RequestedPermissionEnum; shareEncryptionKey?: ShareMetadataBehaviour; sharePatientId?: ShareMetadataBehaviour; }): Promise; /** * Share an existing access log with other data owners, allowing them to access the non-encrypted data of the access log and optionally also the * encrypted content, with read-only or read-write permissions. * @param accessLog the access log to share. * @param delegates associates the id of data owners which will be granted access to the entity, to the following sharing options: * - 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 * - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted * content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). * - sharePatientId: specifies if the id of the patient that this access log refers to should be shared with the delegate. Normally this would * be the same as objectId, but it is encrypted separately from it allowing you to give access to the patient id without giving access to the other * encrypted data of the access log (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}. * @return the updated entity */ shareWithMany(accessLog: AccessLog, delegates: { [delegateId: string]: { shareSecretId?: string[]; requestedPermissions?: RequestedPermissionEnum; shareEncryptionKey?: ShareMetadataBehaviour; sharePatientId?: ShareMetadataBehaviour; }; }): Promise; /** * Share an existing access log with other data owners, allowing them to access the non-encrypted data of the access log and optionally also the * encrypted content, with read-only or read-write permissions. * @param accessLog the access log to share. * @param delegates associates the id of data owners which will be granted access to the entity, to the following sharing options: * - 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 * - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted * content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). * - sharePatientId: specifies if the id of the patient that this access log refers to should be shared with the delegate. Normally this would * be the same as objectId, but it is encrypted separately from it allowing you to give access to the patient id without giving access to the other * encrypted data of the access log (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}. * @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 * the operation failed. */ tryShareWithMany(accessLog: AccessLog, delegates: { [delegateId: string]: { shareSecretIds?: string[]; requestedPermissions?: RequestedPermissionEnum; shareEncryptionKey?: ShareMetadataBehaviour; sharePatientId?: ShareMetadataBehaviour; }; }): Promise>; /** * Retrieves the data owners that have access to the given access log, along with their access levels. * @param entity the access log. * @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. */ getDataOwnersWithAccessTo(entity: AccessLog): Promise<{ permissionsByDataOwnerId: { [p: string]: AccessLevelEnum; }; hasUnknownAnonymousDataOwners: boolean; }>; /** * Retrieves the encryption keys of the given access log. * @param entity the access log. * @return the encryption key ids. */ getEncryptionKeysOf(entity: AccessLog): Promise; /** * Creates or updates de-anonymization metadata for the given access log, allowing the specified delegates to * identify the data owners that have access to it. * @param entity the access log. * @param delegates the data owner ids for which to create de-anonymization metadata. */ createDelegationDeAnonymizationMetadata(entity: AccessLog, delegates: string[]): Promise; /** * Like {@link getConflictsForEntity} but additionally decrypts the conflicting revisions for the given user. * @param user the current user, used to determine the data owner that will decrypt the entities. * @param entityId the id of the access log to retrieve the conflicts for. * @return the decrypted conflicting revisions of the access log. */ getConflictsForEntityWithUser(user: models.User, entityId: string): Promise>; /** * Like {@link declareConflictWinner} but encrypts the winning revision before sending it and decrypts the saved * winner returned by the backend. * @param user the current user, used to determine the data owner that will encrypt/decrypt the entity. * @param request the {@link models.ConflictResolutionRequest} carrying the (decrypted) winning revision and the conflicts to purge. * @return the {@link models.ConflictResolutionResult} with the decrypted saved winner and the conflicts that are still unresolved. */ declareConflictWinnerWithUser(user: models.User, request: models.ConflictResolutionRequest): Promise>; /** * Like {@link getConflictsForEntityWithUser} but targets the entity of the group with the given id. * @param user the current user, used to determine the data owner that will decrypt the entities. * @param groupId the id of the group the access log belongs to. * @param entityId the id of the access log to retrieve the conflicts for. * @return the decrypted conflicting revisions of the access log. */ getConflictsForEntityInGroupWithUser(user: models.User, groupId: string, entityId: string): Promise>; /** * Like {@link declareConflictWinnerWithUser} but targets the entity of the group with the given id. * @param user the current user, used to determine the data owner that will encrypt/decrypt the entity. * @param groupId the id of the group the access log belongs to. * @param request the {@link models.ConflictResolutionRequest} carrying the (decrypted) winning revision and the conflicts to purge. * @return the {@link models.ConflictResolutionResult} with the decrypted saved winner and the conflicts that are still unresolved. */ declareConflictWinnerInGroupWithUser(user: models.User, groupId: string, request: models.ConflictResolutionRequest): Promise>; }