import { KeyManager } from '../sdk/storage/keymanager';
import { Issuer } from 'did-jwt-vc';
import { PersistentStorageClean, StorageFactory } from '../sdk/storage/storage';
import { Name, API, NameType } from '@wharfkit/antelope';
import { TonomyUsername } from '../sdk/util/username';
import { DualWalletResponse, DualWalletRequests } from '../sdk/util/request';
import { KYCPayload, KYCVC } from '../sdk/util';
import { AuthenticationMessage, Communication, Message } from '../sdk';
import { VerifiableCredential, VerifyTonomyVcOptions } from '../sdk/util/ssi/vc';
import { DIDurl, JWT } from '../sdk/util/ssi/types';
import { Signer } from '../sdk/services/blockchain/eosio/transaction';
import { ClientAuthorizationData, IOnPressLoginOptions } from '../sdk/types/User';
export type CallbackResponse = {
    user: ExternalUser;
    data?: {
        kyc?: {
            value: KYCPayload;
            verifiableCredential: KYCVC;
        };
    };
};
/**
 * The storage data for an external user that has logged in with Tonomy ID
 *
 * @param {Name} accountName - the account name of the user
 * @param {TonomyUsername} [username] - the username of the user
 * @param {Name} appPermission - the account name of the app the user is logged in with
 * @param {string} did - the DID of the user
 */
export type ExternalUserStorage = {
    accountName: Name;
    username?: TonomyUsername;
    appPermission: Name;
    did: string;
};
export type VerifyLoginOptions = {
    external?: boolean;
    checkKeys?: boolean;
    keyManager?: KeyManager;
    storageFactory?: StorageFactory;
    responses?: DualWalletResponse;
};
export type LoginWithTonomyMessages = {
    requests: DualWalletRequests;
    loginToCommunication: AuthenticationMessage;
};
/**
 * An external user on a website that is being logged into by a Tonomy ID user
 *
 */
export declare class ExternalUser {
    keyManager: KeyManager;
    storage: ExternalUserStorage & PersistentStorageClean;
    did: string;
    communication: Communication;
    /**
     * Creates a new external user
     *
     * @param {KeyManager} _keyManager - the key manager to use for signing
     * @param {StorageFactory} _storageFactory - the storage factory to use for persistent storage
     */
    constructor(_keyManager: KeyManager, _storageFactory: StorageFactory);
    /**
     * Removes the keys and clear storage
     *
     */
    logout(): Promise<void>;
    /**
     * Retrieves the user from persistent storage if it exists and verifies the keys are valid
     *
     * @property {boolean} [options.autoLogout] - automatically logsout on error if this key is false
     * @property {StorageFactory} [options.storageFactory=browserStorageFactory] - the storage factory to use for persistent storage
     * @property {KeyManager} [options.keyManager=new JsKeyManager()] - the key manager to use for signing
     * @returns {Promise<ExternalUser>} - the user
     */
    static getUser(options?: {
        keyManager?: KeyManager;
        storageFactory?: StorageFactory;
        autoLogout?: boolean;
    }): Promise<ExternalUser>;
    /**
     * Returns the DID URL of the logged in user
     *
     * @returns {Promise<DIDurl>} - the DID of the user
     */
    getDid(): Promise<DIDurl>;
    /**
     * @returns {Promise{DIDurl}} the DID URL of the Tonomy ID wallet with #local fragment
     */
    getWalletDid(): Promise<DIDurl>;
    /**
     * Sets the account name of the user
     *
     * @param {Name} accountName - the account name of the user
     */
    private setAccountName;
    /**
     * Sets the username of the user
     *
     * @param {string} username - the username of the user
     */
    private setUsername;
    /**
     * Sets the permission name of the app the user is logged into
     *
     * @param {Name} appPermission - the account name of the app
     */
    private setAppPermission;
    /**
     * Gets the username of the user
     *
     * @returns {Promise<TonomyUsername>} - the username of the user
     */
    getUsername(): Promise<TonomyUsername | undefined>;
    /**
     * Gets the account name of the user
     *
     * @returns {Promise<Name>} - the account name of the user
     */
    getAccountName(): Promise<Name>;
    /**
     * Gets the permission name of the app the user is logged into
     *
     * @returns {Promise<Name>} - the account name of the app
     */
    getAppPermission(): Promise<Name>;
    /**
     * Redirects the user to login to the app with their Tonomy ID account
     *
     * @description should be called when the user clicks on the login button
     *
     * @param {IOnPressLoginOptions} onPressLoginOptions - options for the login
     * @property {boolean} onPressLoginOptions.redirect - if true, redirects the user to the login page, if false, returns the token
     * @property {string} onPressLoginOptions.callbackPath - the path to redirect the user to after login
     * @param {KeyManager} [keyManager] - the key manager to use to store the keys
     * @returns {Promise<LoginWithTonomyMessages | void>} - if redirect is true, returns void, if redirect is false, returns the login request in the form of a JWT token
     */
    static loginWithTonomy(options: IOnPressLoginOptions, keyManager?: KeyManager): Promise<LoginWithTonomyMessages | void>;
    /**
     * Returns the issuer of the user for use with did-jwt and VCs
     *
     * @returns {Promise<Issuer>} - the issuer of the user
     */
    getIssuer(): Promise<Issuer>;
    /**
     * Receives the login response from Tonomy ID and verifies the login was successful
     *
     * @description should be called in the callback page
     *
     * @param {VerifyLoginOptions} [options] - options for the login
     * @property {boolean} [options.external = true] - if true, verifies the login for an external user, otherwise for the Tonomy SSO website
     * @property {boolean} [options.checkKeys = true] - if true, checks the keys in the keyManager against the blockchain
     * @property {KeyManager} [options.keyManager = new JsKeyManager()] - the key manager to use to storage and manage keys
     * @property {StorageFactory} [options.storageFactory = browserStorageFactory] - the storage factory to use to store data
     *
     * @returns {Promise<CallbackResponse>} an external user object ready to use
     */
    static verifyLoginResponse(options?: VerifyLoginOptions): Promise<CallbackResponse>;
    /**
     * Signs a Verifiable Credential
     *
     * @param {string} id - the id of the VC
     * @param {string | string[]} type - the type of the VC
     * @param {object} data - the data of the VC
     * @property {string} [options.subject] - the subject of the VC
     *
     * @returns {Promise<VerifiableCredential>} - the signed VC
     */
    signVc<T extends object = object>(id: string, type: string | string[], data: T, options?: {
        subject?: string;
    }): Promise<VerifiableCredential<T>>;
    /**
     * Creates a client authorization request
     *
     * @param {T} data - the data of the client authorization request
     *
     * @returns {Promise<JWT>} - the signed client authorization request (a JWT string)
     */
    createClientAuthorization<T extends ClientAuthorizationData = object>(data: T): Promise<JWT>;
    /**
     * Return a signer to use to sign transactions
     *
     * @returns {Promise<Signer>} - the signer to use to sign transactions
     */
    getTransactionSigner(): Signer;
    /**
     * Signs a transaction and send it to the blockchain
     *
     * Note: It is signed with the permission of the current app
     * e.g. if user signed into app "marketcom", this will be the name of the permission used to sign the transaction
     *
     * Note: This is a convenience method that signs one action on one smart contract with the current
     * user's account and app permission. To sign a more complex transaction, get a signer with
     * getTransactionSigner() and use eosjs or @wharfkit/antelope directly
     *
     * @param {Name} contract - the smart contract account name
     * @param {Name} action - the action to sign (function of the smart contract)
     * @param {object} data - the data to sign
     *
     * @returns {Promise<API.v1.PushTransactionResponse>} - the signed transaction
     */
    signTransaction(contract: NameType | TonomyUsername, action: NameType, data: object): Promise<API.v1.PushTransactionResponse>;
    private checkLinkAuthRequirements;
    /**
     * Sends a message to another DID
     *
     * @param {Message} message - the message to send
     */
    sendMessage(message: Message): Promise<void>;
    private loginToCommunication;
}
/**
 * A verified client authorization request
 *
 * @param {JWT} request.jwt - the JWT of the request
 * @param {string} request.id - the unique id of the request
 * @param {string} [request.origin] - the origin of the request
 * @param {string} did - the DID of the user
 * @param {string} account - the account name of the user
 * @param {string} [username] - the username of the user
 * @param {T} data - the data of the request
 */
interface VerifiedClientAuthorization<T extends ClientAuthorizationData = object> {
    request: {
        jwt: JWT;
        id: string;
        origin?: string;
    };
    did: string;
    account: string;
    username?: string;
    data: T;
}
/**
 * Verifies a client authorization request
 *
 * @param {string} clientAuthorization - the client authorization request (JWT string)
 *
 * @returns {Promise<VerifiedClientAuthorization<T>>} - the verified client authorization request with data type T
 */
export declare function verifyClientAuthorization<T extends ClientAuthorizationData = ClientAuthorizationData>(clientAuthorization: JWT, { verifyChainId, verifyUsername, verifyOrigin, }?: VerifyTonomyVcOptions): Promise<VerifiedClientAuthorization<T>>;
export {};
//# sourceMappingURL=externalUser.d.ts.map