import { SecureStore } from './SecureStore' ; import { ModuleUtil } from './ModuleUtil' ; import { KeytarSecureStore } from './KeytarSecureStore' ; import { SettingConfigurations } from '../configurations' ; import * as path from 'path' ; import * as vscode from 'vscode' ; import { FileSystemSecureStore } from './FileSystemSecureStore' ; import { FileSystemUtil } from 'ibm-blockchain-platform-common' ; export class SecureStoreFactory { static async getSecureStore ( ) { const keytar = ModuleUtil . getCoreNodeModule ( 'keytar' ) ; if ( keytar ) { return new KeytarSecureStore ( keytar ) ; } const extensionDirectory = vscode . workspace . getConfiguration ( ) . get ( SettingConfigurations . EXTENSION_DIRECTORY ) ; const resolvedExtensionDirectory = FileSystemUtil . getDirPath ( extensionDirectory ) ; const storePath = path . join ( resolvedExtensionDirectory , 'ibm-blockchain-platform.store' ) ; return new FileSystemSecureStore ( storePath ) ; } }