import { Transaction } from "@stellar/stellar-sdk"; import { Encrypter, GetAuthTokenParams, Key, KeyMetadata, KeyTypeHandler, KeyManagerParams, StoreKeyParams, SignTransactionParams, ChangePasswordParams } from "./Types"; export declare class KeyManager { private encrypterMap; private keyStore; private keyHandlerMap; private keyCache; private shouldCache; private defaultNetworkPassphrase; constructor(params: KeyManagerParams); /** * Register a KeyTypeHandler for a given key type. * @param {KeyTypeHandler} keyHandler - The key handler. */ registerKeyHandler(keyHandler: KeyTypeHandler): void; /** * Register a new encrypter. * @param {Encrypter} encrypter - The encrypter. */ registerEncrypter(encrypter: Encrypter): void; /** * Set the default network passphrase * @param {string} passphrase - The passphrase. */ setDefaultNetworkPassphrase(passphrase: string): void; /** * Stores a key in the keyStore after encrypting it with the encrypterName. * * @async * @param {StoreKeyParams} params - The store key params. * @param {Key | UnstoredKey} params.key Key object to store. an `id` field is optional; if you don't * provide one, we'll generate a random number. The id will be used to read, * change, update, and delete keys. * @param {string} params.password encrypt key with this as the secret * @param {string} params.encrypterName encryption algorithm to use (must have been * registered) * * @returns {Promise} The metadata of the key */ storeKey(params: StoreKeyParams): Promise; /** * Load and decrypt one key, given its id. * @param {string} id - the key id * @param {string} password - the key password * @returns {Key} Decrypted key */ loadKey(id: string, password: string): Promise; /** * Get a list of all stored key ids. * * @returns {Array} List of ids */ loadAllKeyIds(): Promise; /** * Remove the key specified by this key id. * * @async * @param {string} id Specifies which key to remove. * The id is computed as `sha1(private key + public key)`. * @returns {Promise} Metadata of the removed key */ removeKey(id: string): Promise; /** * Sign a transaction using the specified key id. Supports both using a * cached key and going out to the keystore to read and decrypt * * @async * @param {SignTransactionParams} params - the sign transaction params * @param {Transaction} params.transaction - transaction Transaction object to sign * @param {string} params.id - Key to sign with. The id is computed as * `sha1(private key + public key)`. * @param {string} params.password - the key password * @param {{[key: string]: any}} [params.custom] - custom arguments * @returns {Promise} Signed transaction */ signTransaction(params: SignTransactionParams): Promise; /** * Request an auth token from auth server, which can be used to deposit and * withdraw auth-required tokens. * * Under the hood, it fetches a transaction from the auth server, signs that * transaction with the user's key, and returns that transaction for a JWT. * * https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0010.md * * @async * @param {object} params Params object. * @param {string} params.id The user's key to authenticate. The id is * computed as `sha1(private key + public key)`. * @param {string} params.password The password that will decrypt that secret. * @param {string} params.authServer The URL of the authentication server. * @param {Array} params.authServerHomeDomains The home domain(s) of the * authentication server. * @param {string} params.authServerKey Check the challenge transaction * for this key as source and signature. * @param {string} params.clientDomain A domain hosting a SEP-1 stellar.toml * containing a SIGNING_KEY used for verifying the client domain. This will * be used as the 'client_domain' param on the GET /authServer request. * @param {string} params.homeDomain Servers that generate tokens for multiple * Home Domains can use this parameter to identify which home domain the Client * hopes to authenticate with. This will be used as the 'home_domain' param * on the GET /authServer request. * @param {Function} params.onChallengeTransactionSignature When * `params.clientDomain` is set, you need to provide a function that will add * the signature identified by the SIGNING_KEY present on your client domain's * toml file. The callback may only append signatures: the returned * transaction's hash is compared against the validated challenge and a * `DomainSigningModifiedError` is thrown if they differ. That hash covers * the operations, source account, sequence number, memo and network * passphrase, but not the signatures, so appending a signature is the only * change the callback can make. * @param {string} [params.account] The authenticating public key. If not * provided, then the signers's public key will be used instead. * @returns {Promise} authToken JWT. */ fetchAuthToken(params: GetAuthTokenParams): Promise; /** * Update the stored keys to be encrypted with the new password. * * @async * @param {ChangePasswordParams} params - the change password params * @param {string} params.oldPassword - the user's old password * @param {string} params.newPassword - the user's new password * @returns {Promise} the key meta data */ changePassword(params: ChangePasswordParams): Promise; private _readFromCache; private _writeIndexCache; }