import { mkdirSync , promises as fsPromises , readFileSync , unlinkSync , writeFileSync } from 'fs' ; import path from 'path' ; import { KeystoreBase } from './keystore-base' ; export class FileKeystore extends KeystoreBase { /**
     * Implements keystore as a directory on disk
     * with files for keystore entries
     */ private _keystoreDir : string ; param keystoreDir constructor ( keystoreDir ) { super ( ) ; this . _keystoreDir = path . join ( keystoreDir , 'keystore' ) ; mkdirSync ( this . _keystoreDir , { recursive : true } ) ; } returns async getAllKeystoreNames ( ) { return fsPromises . readdir ( this . _keystoreDir ) ; } param keystoreName param keystore persistKeystore ( keystoreName , keystore ) { writeFileSync ( path . join ( this . _keystoreDir , keystoreName ) , keystore ) ; } param keystoreName returns getRawKeystore ( keystoreName ) { return readFileSync ( path . join ( this . _keystoreDir , keystoreName ) ) . toString ( ) ; } param keystoreName removeKeystore ( keystoreName ) { return unlinkSync ( path . join ( this . _keystoreDir , keystoreName ) ) ; } }