import { IccRelatedPersonApi } from '../icc-api/api/IccRelatedPersonApi'; import { IccAuthApi } from '../icc-api'; import { IccCryptoXApi } from './icc-crypto-x-api'; import * as models 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 AccessLevelEnum = SecureDelegation.AccessLevelEnum; import { ShareMetadataBehaviour } from './crypto/ShareMetadataBehaviour'; import { ShareResult } from './utils/ShareResult'; import { EntityShareRequest } from '../icc-api/model/requests/EntityShareRequest'; import RequestedPermissionEnum = EntityShareRequest.RequestedPermissionEnum; import { XHR } from '../icc-api/api/XHR'; import { SubscriptionOptions } from './utils'; import { EncryptedEntityXApi } from './basexapi/EncryptedEntityXApi'; import { AbstractFilter } from './filters/filters'; import { Connection } from '../icc-api/model/Connection'; export declare class IccRelatedPersonXApi extends IccRelatedPersonApi implements EncryptedEntityXApi { private readonly crypto; private readonly dataOwnerApi; private readonly authApi; private readonly autofillAuthor; private readonly encryptedFields; get headers(): Promise>; constructor(host: string, headers: { [key: string]: string; }, crypto: IccCryptoXApi, dataOwnerApi: IccDataOwnerXApi, authApi: IccAuthApi, autofillAuthor: boolean, encryptedKeys?: Array, authenticationProvider?: AuthenticationProvider, fetchImpl?: (input: RequestInfo, init?: RequestInit) => Promise); /** * Creates a new instance of related person with initialised encryption metadata (not in the database). * A related person is a root entity: it is not linked to any owning entity. * @param user the current user. * @param r initialised data for the related person. 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 related person. */ newInstance(user: models.User, r: any, options?: { additionalDelegates?: { [dataOwnerId: string]: AccessLevelEnum; }; ignoreAutoDelegations?: boolean; alternateRootDelegation?: string; }): Promise; /** * @throws always. Use {@link createRelatedPersonWithUser} instead. */ createRelatedPerson(body: models.RelatedPerson): never; /** * Encrypts and creates a related person. * @param user the current user, used for encryption. * @param body the related person to create, with initialised encryption metadata (see {@link newInstance}). * @return the created and decrypted related person. */ createRelatedPersonWithUser(user: models.User, body: models.RelatedPerson): Promise; /** * @throws always. Use {@link createRelatedPersonsWithUser} instead. */ createRelatedPersons(body: Array): never; /** * Encrypts and creates multiple related persons. * @param user the current user, used for encryption. * @param bodies the related persons to create, with initialised encryption metadata (see {@link newInstance}). * @return the created and decrypted related persons. */ createRelatedPersonsWithUser(user: models.User, bodies: Array): Promise>; /** * @throws always. Use {@link getRelatedPersonWithUser} instead. */ getRelatedPerson(relatedPersonId: string): never; /** * Retrieves a related person by id and decrypts it. * @param user the current user, used for decryption. * @param relatedPersonId the id of the related person to retrieve. * @return the decrypted related person. */ getRelatedPersonWithUser(user: models.User, relatedPersonId: string): Promise; /** * @throws always. Use {@link getRelatedPersonsWithUser} instead. */ getRelatedPersons(body: models.ListOfIds): never; /** * Retrieves multiple related persons by their ids and decrypts them. * @param user the current user, used for decryption. * @param body the list of related person ids to retrieve. * @return the decrypted related persons. */ getRelatedPersonsWithUser(user: models.User, body: models.ListOfIds): Promise>; /** * @throws always. Use {@link modifyRelatedPersonWithUser} instead. */ modifyRelatedPerson(body: models.RelatedPerson): never; /** * Encrypts and updates a related person. * @param user the current user, used for encryption. * @param body the related person to update. * @return the updated and decrypted related person. */ modifyRelatedPersonWithUser(user: models.User, body: models.RelatedPerson): Promise; private doModifyRelatedPerson; /** * @throws always. Use {@link modifyRelatedPersonsWithUser} instead. */ modifyRelatedPersons(body: Array): never; /** * Encrypts and updates multiple related persons. * @param user the current user, used for encryption. * @param bodies the related persons to update. * @return the updated and decrypted related persons. */ modifyRelatedPersonsWithUser(user: models.User, bodies: Array): Promise>; /** * @throws always. Use {@link filterByWithUser} instead. */ filterRelatedPersonsBy(body: models.FilterChainRelatedPerson, startDocumentId?: string, limit?: number, collectTiming?: boolean): never; /** * Filters related persons using the provided filter chain and decrypts the results. * @param user the current user, used for decryption. * @param body the filter chain to apply. * @param startDocumentId the pagination start document id. * @param limit the maximum number of results to return. * @param collectTiming add timing information to the response * @return a paginated list of decrypted related persons. */ filterByWithUser(user: models.User, body: models.FilterChainRelatedPerson, startDocumentId?: string, limit?: number, collectTiming?: false): Promise; filterByWithUser(user: models.User, body: models.FilterChainRelatedPerson, startDocumentId?: string, limit?: number, collectTiming?: true): Promise; /** * Encrypts the encrypted fields of a list of related persons. * @param user the current user. * @param relatedPersons the related persons to encrypt. * @return the encrypted related persons. */ encrypt(user: models.User, relatedPersons: Array): Promise>; private doEncrypt; /** * Decrypts a list of related persons using the keys of the current data owner. Related persons which can't be decrypted are returned as they * are, still encrypted. * @param user the current user. * @param relatedPersons the related persons to decrypt. * @return the decrypted related persons. */ decrypt(user: models.User, relatedPersons: Array): Promise>; private doDecrypt; /** * @return if the logged data owner has write access to the content of the given related person */ hasWriteAccess(relatedPerson: models.RelatedPerson): Promise; /** * Retrieves the secret ids of a related person. Since a related person is a root entity these secret ids may be used to link other entities to * it. * @param relatedPerson a related person. * @return the secret ids of the provided related person that the current user can access. */ getSecretIdsOf(relatedPerson: models.RelatedPerson): Promise; /** * Share an existing related person with other data owners, allowing them to access the non-encrypted data of the related person 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 related person. * @param relatedPerson the related person 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 related person 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}). * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}. * @return the updated entity */ shareWith(delegateId: string, relatedPerson: models.RelatedPerson, options?: { shareSecretIds?: string[]; requestedPermissions?: RequestedPermissionEnum; shareEncryptionKey?: ShareMetadataBehaviour; }): Promise; /** * Share an existing related person with other data owners, allowing them to access the non-encrypted data of the related person and optionally * also the encrypted content, with read-only or read-write permissions. * @param relatedPerson the related person 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 related person 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}). * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}. * @return the updated entity. */ shareWithMany(relatedPerson: models.RelatedPerson, delegates: { [delegateId: string]: { shareSecretIds?: string[]; requestedPermissions?: RequestedPermissionEnum; shareEncryptionKey?: ShareMetadataBehaviour; }; }): Promise; /** * Share an existing related person with other data owners, allowing them to access the non-encrypted data of the related person and optionally * also the encrypted content, with read-only or read-write permissions. * @param relatedPerson the related person 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 related person 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}). * - 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(relatedPerson: models.RelatedPerson, delegates: { [delegateId: string]: { shareSecretIds?: string[]; requestedPermissions?: RequestedPermissionEnum; shareEncryptionKey?: ShareMetadataBehaviour; }; }): Promise>; getDataOwnersWithAccessTo(entity: models.RelatedPerson): Promise<{ permissionsByDataOwnerId: { [p: string]: AccessLevelEnum; }; hasUnknownAnonymousDataOwners: boolean; }>; getEncryptionKeysOf(entity: models.RelatedPerson): Promise; createDelegationDeAnonymizationMetadata(entity: models.RelatedPerson, delegates: string[]): Promise; /** * Subscribes to the events of the related persons matching the provided filter. The received related persons are decrypted before being passed to * the `eventFired` callback. * @param eventTypes the types of events to listen to. * @param filter the filter that the related persons must match. * @param eventFired the callback executed on each event. * @param options the options of the subscription. * @return a connection which can be closed to stop the subscription. */ subscribeToRelatedPersonEvents(eventTypes: ('CREATE' | 'UPDATE' | 'DELETE')[], filter: AbstractFilter | undefined, eventFired: (relatedPerson: models.RelatedPerson) => Promise, options?: SubscriptionOptions): 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 related person to retrieve the conflicts for. * @return the decrypted conflicting revisions of the related person. */ 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 related person belongs to. * @param entityId the id of the related person to retrieve the conflicts for. * @return the decrypted conflicting revisions of the related person. */ 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 related person 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>; }