import { KeyPair } from '@near-js/crypto'; import { KeyStore } from '@near-js/keystores'; /** @hidden */ declare function readKeyFile(filename: string): Promise<[string, KeyPair]>; /** * This class is used to store keys on the file system. * * @see [https://docs.near.org/docs/develop/front-end/naj-quick-reference#key-store](https://docs.near.org/docs/develop/front-end/naj-quick-reference#key-store) * @example * ```js * const { homedir } = require('os'); * const { connect, keyStores } = require('near-api-js'); * * const keyStore = new keyStores.UnencryptedFileSystemKeyStore(`${homedir()}/.near-credentials`); * const config = { * keyStore, // instance of UnencryptedFileSystemKeyStore * networkId: 'testnet', * nodeUrl: 'https://rpc.testnet.near.org', * walletUrl: 'https://wallet.testnet.near.org', * helperUrl: 'https://helper.testnet.near.org', * explorerUrl: 'https://explorer.testnet.near.org' * }; * * // inside an async function * const near = await connect(config) * ``` */ declare class UnencryptedFileSystemKeyStore extends KeyStore { /** @hidden */ readonly keyDir: string; /** * @param keyDir base directory for key storage. Keys will be stored in `keyDir/networkId/accountId.json` */ constructor(keyDir: string); /** * Store a {@link KeyPair} in an unencrypted file * @param networkId The targeted network. (ex. default, betanet, etc…) * @param accountId The NEAR account tied to the key pair * @param keyPair The key pair to store in local storage */ setKey(networkId: string, accountId: string, keyPair: KeyPair): Promise; /** * Gets a {@link KeyPair} from an unencrypted file * @param networkId The targeted network. (ex. default, betanet, etc…) * @param accountId The NEAR account tied to the key pair * @returns {Promise} */ getKey(networkId: string, accountId: string): Promise; /** * Deletes an unencrypted file holding a {@link KeyPair} * @param networkId The targeted network. (ex. default, betanet, etc…) * @param accountId The NEAR account tied to the key pair */ removeKey(networkId: string, accountId: string): Promise; /** * Deletes all unencrypted files from the `keyDir` path. */ clear(): Promise; /** @hidden */ private getKeyFilePath; /** * Get the network(s) from files in `keyDir` * @returns {Promise} */ getNetworks(): Promise; /** * Gets the account(s) files in `keyDir/networkId` * @param networkId The targeted network. (ex. default, betanet, etc…) */ getAccounts(networkId: string): Promise; /** @hidden */ toString(): string; } export { UnencryptedFileSystemKeyStore, readKeyFile };