import type Wallet from "ethereumjs-wallet"; import type { CreateKey, GetFn, LocalStorage, SetAuthFn, SetUserFn } from "./types"; export declare class Hedgehog { getFn: GetFn; setAuthFn: SetAuthFn; setUserFn: SetUserFn; wallet: null | Wallet; localStorage: LocalStorage; createKey: CreateKey; ready: boolean; constructor(getFn?: GetFn, setAuthFn?: SetAuthFn, setUserFn?: SetUserFn, useLocalStorage?: boolean, localStorage?: any, createKey?: (encryptStr: string, ivHex: string) => Promise); /** * Helper function to check if Hedgehog instance is ready. * Only needed if `useLocalStorage = true` * Otherwise, Hedgehog will be ready as soon as it is constructed. */ isReady(): boolean; /** * Helper function to wait until Hedgehog instance is ready. * Only needed if `useLocalStorage = true` * Otherwise, Hedgehog will be ready as soon as it is constructed. */ waitUntilReady(): Promise; /** * Given user credentials, create a client side wallet and all other authentication artifacts, * call setFn to persist the artifacts to a server and return the wallet object * @param username username * @param password user password * @returns ethereumjs-wallet wallet object */ signUp(username: string, password: string): Promise; /** * Generate new set of auth credentials to allow login * If the old password is included, the setAuthFn will include the old lookup key for deletion * @param username - username * @param password - new password */ resetPassword(username: string, password: string): Promise; /** * Generate new set of auth credentials to allow login and remove the old password * Note: Doesn't log out on error * @param username - username * @param password - new password * @param oldPassword - old password */ changePassword(username: string, password: string, oldPassword: string): Promise; /** * Given user credentials, attempt to get authentication artifacts from server using * getFn, create the private key using the artifacts and the user password * @param username username * @param password user password * @returns ethereumjs-wallet wallet object */ login(username: string, password: string): Promise; /** * Confirms the user credentials given generate the same entropy after using artifacts from the server * @param username username * @param password user password * @returns whether or not the credentials are valid for the current user */ confirmCredentials(username: string, password: string): Promise; /** * Deletes the local client side wallet including entropy and all associated * authentication artifacts */ logout(): Promise; /** * Returns is the user has a client side wallet. If they do, calls can be made against * that wallet, if they don't the user has to login or signup * @returns true if the user has a client side wallet, false otherwise */ isLoggedIn(): boolean; /** * Returns the current user wallet * @returns ethereumjs-wallet wallet object if a wallet exists, otherwise null */ getWallet(): Wallet | null; /** * If a user refreshes or navigates away from the page and comes back later, this attempts * to restore the client side wallet from localStorage, if it exists * @returns If the user has a wallet client side, the wallet object is returned, * otherwise null is returned */ restoreLocalWallet(): Promise; /** * Create a new client side wallet object without going through the signup flow. This is useful * if you need a temporary, read-only wallet that is ephemeral and does not need to be persisted * @param password user password * @returns ethereumjs-wallet wallet object */ createWalletObj(password: string): Promise; }