diff --git a/tabby-ssh/src/algorithms.ts b/tabby-ssh/src/algorithms.ts new file mode 100644 index 00000000..4a69d93b --- /dev/null +++ b/tabby-ssh/src/algorithms.ts @@ -0,0 +1,14 @@ +import { ALGORITHM_BLACKLIST, SSHAlgorithmType } from './api' +import * as ALGORITHMS from 'ssh2/lib/protocol/constants' + +export const supportedAlgorithms: Record = {} + +for (const k of Object.values(SSHAlgorithmType)) { + const supportedAlg = { + [SSHAlgorithmType.KEX]: 'SUPPORTED_KEX', + [SSHAlgorithmType.HOSTKEY]: 'SUPPORTED_SERVER_HOST_KEY', + [SSHAlgorithmType.CIPHER]: 'SUPPORTED_CIPHER', + [SSHAlgorithmType.HMAC]: 'SUPPORTED_MAC', + }[k] + supportedAlgorithms[k] = ALGORITHMS[supportedAlg].filter(x => !ALGORITHM_BLACKLIST.includes(x)).sort() +} diff --git a/tabby-ssh/src/components/sshProfileSettings.component.ts b/tabby-ssh/src/components/sshProfileSettings.component.ts index a7ce5ad7..410014e3 100644 --- a/tabby-ssh/src/components/sshProfileSettings.component.ts +++ b/tabby-ssh/src/components/sshProfileSettings.component.ts @@ -6,7 +6,7 @@ import { ConfigService, FileProvidersService, Platform, HostAppService, PromptMo import { LoginScriptsSettingsComponent } from 'tabby-terminal' import { PasswordStorageService } from '../services/passwordStorage.service' import { ForwardedPortConfig, SSHAlgorithmType, SSHProfile } from '../api' -import { SSHProfilesService } from '../profiles' +import { supportedAlgorithms } from '../algorithms' /** @hidden */ @Component({ @@ -18,7 +18,7 @@ export class SSHProfileSettingsComponent { hasSavedPassword: boolean useProxyCommand: boolean - supportedAlgorithms: Record = {} + supportedAlgorithms = supportedAlgorithms algorithms: Record> = {} jumpHosts: SSHProfile[] @ViewChild('loginScriptsSettings') loginScriptsSettings: LoginScriptsSettingsComponent|null @@ -29,10 +29,7 @@ export class SSHProfileSettingsComponent { private passwordStorage: PasswordStorageService, private ngbModal: NgbModal, private fileProviders: FileProvidersService, - sshProfilesService: SSHProfilesService, - ) { - this.supportedAlgorithms = sshProfilesService.supportedAlgorithms - } + ) { } async ngOnInit () { this.jumpHosts = this.config.store.profiles.filter(x => x.type === 'ssh' && x !== this.profile) diff --git a/tabby-ssh/src/profiles.ts b/tabby-ssh/src/profiles.ts index 37a8e7bf..80ee5605 100644 --- a/tabby-ssh/src/profiles.ts +++ b/tabby-ssh/src/profiles.ts @@ -4,9 +4,9 @@ import { SSHProfileSettingsComponent } from './components/sshProfileSettings.com import { SSHTabComponent } from './components/sshTab.component' import { PasswordStorageService } from './services/passwordStorage.service' import { ALGORITHM_BLACKLIST, SSHAlgorithmType, SSHProfile } from './api' - import * as ALGORITHMS from 'ssh2/lib/protocol/constants' + @Injectable({ providedIn: 'root' }) export class SSHProfilesService extends ProfileProvider { id = 'ssh' @@ -41,26 +41,17 @@ export class SSHProfilesService extends ProfileProvider { }, } - supportedAlgorithms: Record = {} - constructor ( private passwordStorage: PasswordStorageService ) { super() for (const k of Object.values(SSHAlgorithmType)) { - const supportedAlg = { - [SSHAlgorithmType.KEX]: 'SUPPORTED_KEX', - [SSHAlgorithmType.HOSTKEY]: 'SUPPORTED_SERVER_HOST_KEY', - [SSHAlgorithmType.CIPHER]: 'SUPPORTED_CIPHER', - [SSHAlgorithmType.HMAC]: 'SUPPORTED_MAC', - }[k] const defaultAlg = { [SSHAlgorithmType.KEX]: 'DEFAULT_KEX', [SSHAlgorithmType.HOSTKEY]: 'DEFAULT_SERVER_HOST_KEY', [SSHAlgorithmType.CIPHER]: 'DEFAULT_CIPHER', [SSHAlgorithmType.HMAC]: 'DEFAULT_MAC', }[k] - this.supportedAlgorithms[k] = ALGORITHMS[supportedAlg].filter(x => !ALGORITHM_BLACKLIST.includes(x)).sort() this.configDefaults.options.algorithms[k] = ALGORITHMS[defaultAlg].filter(x => !ALGORITHM_BLACKLIST.includes(x)) this.configDefaults.options.algorithms[k].sort() } diff --git a/tabby-web-demo/src/index.ts b/tabby-web-demo/src/index.ts index 430a9e5d..7c58e936 100644 --- a/tabby-web-demo/src/index.ts +++ b/tabby-web-demo/src/index.ts @@ -7,7 +7,7 @@ import TabbyCorePlugin, { ProfileProvider, AppService } from 'tabby-core' import TabbyTerminalModule from 'tabby-terminal' import { DemoTerminalTabComponent } from './components/terminalTab.component' -import { DemoProfilesService } from 'profiles' +import { DemoProfilesService } from './profiles' /** @hidden */ @NgModule({ diff --git a/tabby-web-demo/src/session.ts b/tabby-web-demo/src/session.ts index fd8b4d9b..53fc2277 100644 --- a/tabby-web-demo/src/session.ts +++ b/tabby-web-demo/src/session.ts @@ -2,7 +2,7 @@ import { Injector, NgZone } from '@angular/core' import * as path from 'path' import { BaseSession } from 'tabby-terminal' -import { Logger } from '../../tabby-core/typings' +import { Logger } from 'tabby-core' const currentScript: any = document.currentScript @@ -32,7 +32,7 @@ export class Session extends BaseSession { Session.v86Loaded = true } script.src = `${this.dataPath}/v86_all.js` - document.querySelector('head').appendChild(script) + document.querySelector('head')?.appendChild(script) }) } @@ -94,7 +94,7 @@ export class Session extends BaseSession { return false } - getWorkingDirectory (): Promise { + async getWorkingDirectory (): Promise { return null } } diff --git a/tabby-web-demo/tsconfig.json b/tabby-web-demo/tsconfig.json index 462ae01d..a863b98a 100644 --- a/tabby-web-demo/tsconfig.json +++ b/tabby-web-demo/tsconfig.json @@ -1,25 +1,7 @@ { + "extends": "../tsconfig.json", + "exclude": ["node_modules", "dist", "typings"], "compilerOptions": { - "baseUrl": "src", - "module": "commonjs", - "target": "es2016", - "esModuleInterop": true, - "noImplicitAny": false, - "removeComments": false, - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "sourceMap": true, - "noUnusedParameters": true, - "noImplicitReturns": true, - "noFallthroughCasesInSwitch": true, - "noUnusedLocals": true, - "declaration": true, - "declarationDir": "dist", - "lib": [ - "dom", - "es2015", - "es7" - ] - }, - "exclude": ["node_modules", "dist"] + "baseUrl": "src" + } } diff --git a/tabby-web-demo/webpack.config.js b/tabby-web-demo/webpack.config.js index 6ee24f15..c2c908c3 100644 --- a/tabby-web-demo/webpack.config.js +++ b/tabby-web-demo/webpack.config.js @@ -1,42 +1,5 @@ -const path = require('path') - -module.exports = { - target: 'node', - entry: 'src/index.ts', - devtool: 'source-map', - context: __dirname, - mode: 'development', - output: { - path: path.resolve(__dirname, 'dist'), - filename: 'index.js', - pathinfo: true, - libraryTarget: 'umd', - devtoolModuleFilenameTemplate: 'webpack-tabby-demo:///[resource-path]', - }, - resolve: { - modules: ['.', 'src', 'node_modules'].map(x => path.join(__dirname, x)), - extensions: ['.ts', '.js'], - }, - module: { - rules: [ - { - test: /\.ts$/, - loader: 'ts-loader', - options: { - configFile: path.resolve(__dirname, 'tsconfig.json'), - }, - }, - { test: /\.pug$/, use: ['apply-loader', 'pug-loader'] }, - { test: /\.svg/, use: ['svg-inline-loader'] }, - ], - }, - externals: [ - 'fs', - 'ngx-toastr', - 'path', - /^rxjs/, - /^@angular/, - /^@ng-bootstrap/, - /^tabby-/, - ], -} +const config = require('../webpack.plugin.config') +module.exports = config({ + name: 'web-demo', + dirname: __dirname, +})