import { DataOwnerOrStub, IccDataOwnerXApi } from '../icc-data-owner-x-api';
import { KeyPair } from './RSA';
import { IcureStorageFacade } from '../storage/IcureStorageFacade';
import { CryptoPrimitives } from './CryptoPrimitives';
import { KeyRecovery } from './KeyRecovery';
import { CryptoStrategies } from './CryptoStrategies';
import { KeyPairRecoverer } from './KeyPairRecoverer';
/**
 * Allows to manage public and private keys for the current user and his parent hierarchy.
 */
export declare class UserEncryptionKeysManager {
    private readonly primitives;
    private readonly dataOwnerApi;
    private readonly icureStorage;
    private readonly keyRecovery;
    private readonly strategies;
    private readonly initialiseParentKeys;
    private readonly keypairRecoverer;
    private readonly selfIsAnonymous;
    private selfId;
    private selfLegacyPublicKey;
    private keysCache;
    constructor(primitives: CryptoPrimitives, dataOwnerApi: IccDataOwnerXApi, icureStorage: IcureStorageFacade, keyRecovery: KeyRecovery, strategies: CryptoStrategies, initialiseParentKeys: boolean, keypairRecoverer: KeyPairRecoverer, selfIsAnonymous: boolean);
    /**
     * @internal
     * Get all key pairs available for the current data owner and his parents.
     * @return an object with:
     * - `self` an object containing the current data owner id and the list of key pairs available for the current data owner with verification details.
     * - `parents` the list of parents to the current data owner with the list of key pairs available for each parent. The list is ordered from the
     *   topmost ancestor (at index 0) to the direct parent of the current data owner (at the last index, may be 0).
     */
    getCurrentUserHierarchyAvailableKeypairs(): Promise<{
        self: {
            dataOwnerId: string;
            keys: {
                pair: KeyPair<CryptoKey>;
                verified: boolean;
            }[];
        };
        parents: {
            dataOwnerId: string;
            keys: {
                pair: KeyPair<CryptoKey>;
                verified: boolean;
            }[];
        }[];
    }>;
    /**
     * Get the public keys of available key pairs for the current user in hex-encoded spki representation (uses cached keys: no request is done to the
     * server).
     * By setting {@link verifiedOnly} to true only the public keys for verified key pairs will be returned: these will include only key pairs created
     * on this device or which have been verified using {@link CryptoStrategies} on this device.
     * @param verifiedOnly if true only the verified public keys will be returned.
     * @return the spki representation of public keys of available keypairs for the current user.
     */
    getCurrentUserAvailablePublicKeysHex(verifiedOnly: boolean): Promise<string[]>;
    /**
     * Get the public keys of available key pairs for the current user and his parents in hex-encoded spki representation (uses cached keys: no request
     * is done to the server).
     * Note that this will also include unverified keys.
     * @return the spki representation of public keys of available keypairs for the current user.
     */
    getCurrentUserHierarchyAvailablePublicKeysHex(): Promise<string[]>;
    /**
     * Get a key pair with the provided fingerprint if present.
     * @param fingerprint a key-pair/public-key fingerprint
     * @return the pair associated to the fingerprint and a boolean indicating if the pair is verified, if present, else undefined
     */
    getKeyPairForFingerprint(fingerprint: string): {
        pair: KeyPair<CryptoKey>;
        verified: boolean;
    } | undefined;
    /**
     * @internal This method is intended for internal use only and may be changed without notice.
     * Initializes all keys for the current data owner. This method needs to be called before any other method of this class can be used.
     * @throws if the current user is not a data owner, or if there is no key and no new key could be created according to this manager crypt
     * strategies.
     * @return if a new key was created during initialisation the newly created key, else undefined.
     */
    initialiseKeys(): Promise<{
        newKeyPair: KeyPair<CryptoKey>;
        newKeyFingerprint: string;
    } | undefined>;
    /**
     * @internal This method is intended for internal use only and may be changed without notice.
     * Forces to reload keys for the current data owner. This could be useful if the data owner has logged in from another device in order to update the
     * transfer keys.
     * This method will complete only after keys have been reloaded successfully.
     */
    reloadKeys(): Promise<void>;
    /**
     * @internal This method is intended for internal use only and may be changed without notice.
     * Get all verified key pairs for the current data owner which can safely be used for encryption. This includes all key pairs created on the current
     * device and all recovered key pairs which have been verified.
     * The keys returned by this method will be in the following order:
     * 1. Legacy key pair if it is verified
     * 2. All device key pais, in alphabetical order according to the fingerprint
     * 3. Other verified key pairs, in alphabetical order according to the fingerprint
     * @return all verified keys, in order.
     */
    getSelfVerifiedKeys(): {
        fingerprint: string;
        pair: KeyPair<CryptoKey>;
    }[];
    /**
     * Get all verified keys for a member of the current data owner hierarchy in no particular order.
     * @param dataOwner the current data owner or a member of his hierarchy.
     * @throws if the provided data owner is not part of the current data owner hierarchy
     */
    getVerifiedPublicKeysFor(dataOwner: DataOwnerOrStub): Promise<string[]>;
    /**
     * @internal This method is intended for internal use only and may be changed without notice.
     * Get all key pairs for the current data owner and his parents. These keys should be used only for decryption as they may have not been verified.
     * @return all key pairs available for decryption.
     */
    getDecryptionKeys(): {
        [fingerprint: string]: KeyPair<CryptoKey>;
    };
    private doLoadKeys;
    private createAndSaveNewKeyPair;
    private loadStoredKeys;
    private verifyKeys;
    private plainKeysByFingerprint;
    private ensureInitialised;
    private recoverAndCacheKeys;
    private loadAndRecoverKeysFor;
    private ensureFingerprintKeys;
    private hasVerifiedKey;
}
