import { IccAuthApi, IccTopicApi } from '../icc-api'; import { IccCryptoXApi } from './icc-crypto-x-api'; import * as models from '../icc-api/model/models'; import { ListOfIds, TimingInfo, Topic, TopicRole } 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 { ShareResult } from './utils/ShareResult'; import { EntityShareRequest } from '../icc-api/model/requests/EntityShareRequest'; import { XHR } from '../icc-api/api/XHR'; import { EncryptedEntityXApi } from './basexapi/EncryptedEntityXApi'; import { FilterChainTopic } from '../icc-api/model/FilterChainTopic'; import { PaginatedListTopic } from '../icc-api/model/PaginatedListTopic'; import AccessLevelEnum = SecureDelegation.AccessLevelEnum; import RequestedPermissionEnum = EntityShareRequest.RequestedPermissionEnum; import { SubscriptionOptions } from './utils'; import { AbstractFilter } from './filters/filters'; import { Connection } from '../icc-api/model/Connection'; import { SecretIdUseOption } from './crypto/SecretIdUseOption'; export declare class IccTopicXApi extends IccTopicApi implements EncryptedEntityXApi { private readonly crypto; private readonly dataOwnerApi; private readonly authApi; private readonly autofillAuthor; private readonly encryptedFields; constructor(host: string, headers: { [key: string]: string; }, crypto: IccCryptoXApi, dataOwnerApi: IccDataOwnerXApi, authApi: IccAuthApi, autofillAuthor: boolean, authenticationProvider?: AuthenticationProvider, encryptedKeys?: Array, fetchImpl?: (input: RequestInfo, init?: RequestInit) => Promise); get headers(): Promise>; /** * Creates a new instance of topic with initialised encryption metadata (not in the database). * @param user the current user. * @param patient the patient this topic refers to. * @param c initialised data for the topic. 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 topic. */ newInstance(user: models.User, patient: models.Patient | null, c?: Topic, // TODO: Why this isn't Topic? options?: { additionalDelegates?: { [dataOwnerId: string]: AccessLevelEnum; }; sfkOption?: SecretIdUseOption; ignoreAutoDelegations?: boolean; alternateRootDelegation?: string; }): Promise; decrypt(topics: Array): Promise; encrypt(topics: Array): Promise>; /** * Create and share a new topic with other participants. * @param body the topic to create. * @return the created topic. */ createTopic(body: Topic): Promise; /** * @param topic a topic * @return the id of the patient that the topic refers to, retrieved from the encrypted metadata. Normally there should only be one element * in the returned array, but in case of entity merges there could be multiple values. */ decryptPatientIdOf(topic: models.Topic): Promise; /** * @return if the logged data owner has write access to the content of the given topic */ hasWriteAccess(topic: models.Topic): Promise; /** * Share an existing topic with other data owners, allowing them to access the non-encrypted data of the topic 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 topic. * @param topic the topic 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 topic refers to should be shared with the delegate (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, topic: models.Topic, options?: { shareSecretIds?: string[]; requestedPermissions?: RequestedPermissionEnum; shareEncryptionKey?: ShareMetadataBehaviour; sharePatientId?: ShareMetadataBehaviour; }): Promise; /** * Share an existing topic with other data owners, allowing them to access the non-encrypted data of the topic and optionally also * the encrypted content, with read-only or read-write permissions. * @param topic the topic 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}). Note that by default a * topic does not have encrypted content. * - sharePatientId: specifies if the id of the patient that this topic refers to should be shared with the delegate (defaults to * {@link ShareMetadataBehaviour.IF_AVAILABLE}). * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}. * @return the updated entity */ shareWithMany(topic: models.Topic, delegates: { [delegateId: string]: { shareSecretIds?: string[]; requestedPermissions?: RequestedPermissionEnum; shareEncryptionKey?: ShareMetadataBehaviour; sharePatientId?: ShareMetadataBehaviour; }; }): Promise; /** * Share an existing topic with other data owners, allowing them to access the non-encrypted data of the topic and optionally also * the encrypted content, with read-only or read-write permissions. * @param topic the topic 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}). Note that by default a * topic does not have encrypted content. * - sharePatientId: specifies if the id of the patient that this topic refers to should be shared with the delegate (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(topic: models.Topic, delegates: { [delegateId: string]: { shareSecretIds?: string[]; requestedPermissions?: RequestedPermissionEnum; shareEncryptionKey?: ShareMetadataBehaviour; sharePatientId?: ShareMetadataBehaviour; }; }): Promise>; getDataOwnersWithAccessTo(entity: models.Topic): Promise<{ permissionsByDataOwnerId: { [p: string]: AccessLevelEnum; }; hasUnknownAnonymousDataOwners: boolean; }>; getEncryptionKeysOf(entity: models.Topic): Promise; /** * Filter and decrypt topics by the given filter. * @param body the filter to apply. * @param startDocumentId the document id to start from (inclusive). * @param limit the maximum number of topics to return in the page. * @param collectTiming add timing information to the response * @return a paginated list of topics. */ filterTopicsBy(body: FilterChainTopic, startDocumentId?: string, limit?: number, collectTiming?: false): Promise; filterTopicsBy(body: FilterChainTopic, startDocumentId?: string, limit?: number, collectTiming?: true): Promise; /** * Obtain the topic with the given id and decrypt it. * @param id the id of the topic to retrieve. * @return the decrypted topic. */ getTopic(id: string): Promise; /** * Obtain the topics with the given ids and decrypt them. * @param body the ids of the topics to retrieve. * @return the decrypted topics. */ getTopics(body: ListOfIds): Promise>; /** * Update and encrypt the given topic. * @param body the topic to update. * @return the updated decrypted topic. */ modifyTopic(body: Topic): Promise; /** * @internal this method is for internal use only and may be changed without notice * @param body data owner id of the data owner to which the participant should be added and the topic role of the participant. * @param topicId Id of the topic to which the participant should be added. */ addParticipant(body: { dataOwnerId: string; topicRole: TopicRole; }, topicId: string): Promise; /** * This method is similar to {@link addParticipant} but it also shares the topic with the data owner before adding the participant. * @param body data owner id of the data owner to which the participant should be added and the topic role of the participant. * @param topic the topic to share and to which the participant should be added. * @return the updated topic. */ addParticipantWithTopic(body: { dataOwnerId: string; topicRole: TopicRole; }, topic: Topic): Promise; /** * Remove the participant with the given data owner id from the topic with the given id. * @param body data owner id of the participant to remove. * @param topicId Id of the topic from which the participant should be removed. * @return the updated decrypted topic. */ removeParticipant(body: { dataOwnerId: string; }, topicId: string): Promise; subscribeToTopicEvents(eventTypes: ('CREATE' | 'UPDATE' | 'DELETE')[], filter: AbstractFilter | undefined, eventFired: (message: Topic) => Promise, options?: SubscriptionOptions): Promise; createDelegationDeAnonymizationMetadata(entity: Topic, delegates: string[]): Promise; /** * Like {@link getConflictsForEntity} but additionally decrypts the conflicting revisions for the given user. * @param user the current user. * @param entityId the id of the topic to retrieve the conflicts for. * @return the decrypted conflicting revisions of the topic. */ 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. * @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. * @param groupId the id of the group the topic belongs to. * @param entityId the id of the topic to retrieve the conflicts for. * @return the decrypted conflicting revisions of the topic. */ 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. * @param groupId the id of the group the topic 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>; }