mirror of
https://github.com/Eugeny/tabby.git
synced 2025-10-05 06:24:56 +00:00
allow storing private keys in the vault
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { NgModule } from '@angular/core'
|
||||
import { PlatformService, LogService, UpdaterService, DockingService, HostAppService, ThemesService, Platform, AppService, ConfigService, ElectronService, WIN_BUILD_FLUENT_BG_SUPPORTED, isWindowsBuild, HostWindowService, HotkeyProvider, ConfigProvider } from 'terminus-core'
|
||||
import { PlatformService, LogService, UpdaterService, DockingService, HostAppService, ThemesService, Platform, AppService, ConfigService, ElectronService, WIN_BUILD_FLUENT_BG_SUPPORTED, isWindowsBuild, HostWindowService, HotkeyProvider, ConfigProvider, FileProvider } from 'terminus-core'
|
||||
import { TerminalColorSchemeProvider } from 'terminus-terminal'
|
||||
|
||||
import { HyperColorSchemes } from './colorSchemes'
|
||||
@@ -9,6 +9,7 @@ import { ElectronUpdaterService } from './services/updater.service'
|
||||
import { TouchbarService } from './services/touchbar.service'
|
||||
import { ElectronDockingService } from './services/docking.service'
|
||||
import { ElectronHostWindow } from './services/hostWindow.service'
|
||||
import { ElectronFileProvider } from './services/fileProvider.service'
|
||||
import { ElectronHostAppService } from './services/hostApp.service'
|
||||
import { ElectronHotkeyProvider } from './hotkeys'
|
||||
import { ElectronConfigProvider } from './config'
|
||||
@@ -24,6 +25,7 @@ import { ElectronConfigProvider } from './config'
|
||||
{ provide: DockingService, useClass: ElectronDockingService },
|
||||
{ provide: HotkeyProvider, useClass: ElectronHotkeyProvider, multi: true },
|
||||
{ provide: ConfigProvider, useClass: ElectronConfigProvider, multi: true },
|
||||
{ provide: FileProvider, useClass: ElectronFileProvider, multi: true },
|
||||
],
|
||||
})
|
||||
export default class ElectronModule {
|
||||
|
40
terminus-electron/src/services/fileProvider.service.ts
Normal file
40
terminus-electron/src/services/fileProvider.service.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { promises as fs } from 'fs'
|
||||
import { Injectable } from '@angular/core'
|
||||
import { ElectronService, FileProvider } from 'terminus-core'
|
||||
import { ElectronHostWindow } from './hostWindow.service'
|
||||
|
||||
@Injectable()
|
||||
export class ElectronFileProvider extends FileProvider {
|
||||
name = 'Filesystem'
|
||||
|
||||
constructor (
|
||||
private electron: ElectronService,
|
||||
private hostWindow: ElectronHostWindow,
|
||||
) {
|
||||
super()
|
||||
}
|
||||
|
||||
async selectAndStoreFile (description: string): Promise<string> {
|
||||
const result = await this.electron.dialog.showOpenDialog(
|
||||
this.hostWindow.getWindow(),
|
||||
{
|
||||
buttonLabel: `Select ${description}`,
|
||||
properties: ['openFile', 'treatPackageAsDirectory'],
|
||||
},
|
||||
)
|
||||
if (result.canceled || !result.filePaths.length) {
|
||||
throw new Error('canceled')
|
||||
}
|
||||
|
||||
return `file://${result.filePaths[0]}`
|
||||
}
|
||||
|
||||
async retrieveFile (key: string): Promise<Buffer> {
|
||||
if (key.startsWith('file://')) {
|
||||
key = key.substring('file://'.length)
|
||||
} else if (key.includes('://')) {
|
||||
throw new Error('Incorrect type')
|
||||
}
|
||||
return fs.readFile(key, { encoding: null })
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user