Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support private key forwarding to winscp #7143

Merged
merged 20 commits into from Sep 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 27 additions & 0 deletions .all-contributorsrc
Expand Up @@ -920,6 +920,33 @@
"contributions": [
"doc"
]
},
{
"login": "daniel347x",
"name": "Dan Nissenbaum",
"avatar_url": "https://avatars.githubusercontent.com/u/309746?v=4",
"profile": "https://github.com/daniel347x",
"contributions": [
"financial"
]
},
{
"login": "DunklerPhoenix",
"name": "RogueThorn",
"avatar_url": "https://avatars.githubusercontent.com/u/1261305?v=4",
"profile": "https://github.com/DunklerPhoenix",
"contributions": [
"financial"
]
},
{
"login": "spenserblack",
"name": "Spenser Black",
"avatar_url": "https://avatars.githubusercontent.com/u/8546709?v=4",
"profile": "http://spenserblack.github.io",
"contributions": [
"code"
]
}
],
"contributorsPerLine": 7,
Expand Down
39 changes: 39 additions & 0 deletions .editorconfig
@@ -0,0 +1,39 @@
root = true

[*]
end_of_line = LF
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.sln]
indent_style = tab
# TODO Determine if there is a preferred tab width for this file type

# Programming/Scripts
[*.{js,ts}]
indent_style = space
indent_size = 4

[*.cpp]
indent_style = tab
# TODO Determine if there is a preferred tab width for this file type

# Markup
[*.pug]
indent_style = space
indent_size = 4

# Stylesheets
[*.scss]
indent_style = space
indent_size = 4

# Data Files
[*.json]
indent_style = space
indent_size = 2

[*.{yaml,yml}]
indent_style = space
indent_size = 2
265 changes: 135 additions & 130 deletions README.de-DE.md

Large diffs are not rendered by default.

265 changes: 135 additions & 130 deletions README.id-ID.md

Large diffs are not rendered by default.

265 changes: 135 additions & 130 deletions README.it-IT.md

Large diffs are not rendered by default.

265 changes: 135 additions & 130 deletions README.ja-JP.md

Large diffs are not rendered by default.

265 changes: 135 additions & 130 deletions README.ko-KR.md

Large diffs are not rendered by default.

265 changes: 135 additions & 130 deletions README.md

Large diffs are not rendered by default.

265 changes: 135 additions & 130 deletions README.ru-RU.md

Large diffs are not rendered by default.

265 changes: 135 additions & 130 deletions README.zh-CN.md

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions tabby-community-color-schemes/.editorconfig
@@ -0,0 +1,3 @@
[schemes/*]
indent_style = space
indent_size = 15
44 changes: 44 additions & 0 deletions tabby-community-color-schemes/schemes/Melange Dark
@@ -0,0 +1,44 @@
!
! Melange Dark
! https://github.com/savq/melange
!
*.foreground: #ece1d7
*.background: #2a2520
*.cursorColor: #ece1d7
!
! Black
*.color0: #352f2a
*.color8: #4d453e
!
! Red
*.color1 #b65c60
*.color9 #f17c64
!
! Green
*.color2 #78997a
*.color10 #99d59d
!
! Yellow
*.color3 #ebc06d
*.color11 #ebc06d
!
! Blue
*.color4 #9aacce
*.color12 #9aacce
!
! Magenta
*.color5 #b380b0
*.color13 #ce9bcb
!
! Cyan
*.color6 #86a3a3
*.color14 #88b3b2
!
! White
*.color7 #a38d78
*.color15 #c1a78e
!
! Bold, Italic, Underline
*.colorBD: #fff4ea
!*.colorIT:
!*.colorUL:
2 changes: 1 addition & 1 deletion tabby-core/src/api/platform.ts
Expand Up @@ -145,7 +145,7 @@ export abstract class PlatformService {
throw new Error('Not implemented')
}

exec (app: string, argv: string[]): void {
async exec (app: string, argv: string[]): Promise<void> {
throw new Error('Not implemented')
}

Expand Down
2 changes: 1 addition & 1 deletion tabby-core/src/tabContextMenu.ts
Expand Up @@ -28,7 +28,7 @@ export class TabManagementContextMenu extends TabContextMenuItemProvider {
super()
}

async getItems (tab: BaseTabComponent, tabHeader?: TabHeaderComponent): Promise<MenuItemOptions[]> {
async getItems (tab: BaseTabComponent): Promise<MenuItemOptions[]> {
let items: MenuItemOptions[] = [
{
label: this.translate.instant('Close'),
Expand Down
4 changes: 2 additions & 2 deletions tabby-electron/src/services/platform.service.ts
Expand Up @@ -80,8 +80,8 @@ export class ElectronPlatformService extends PlatformService {
return null
}

exec (app: string, argv: string[]): void {
execFile(app, argv)
async exec (app: string, argv: string[]): Promise<void> {
await execFile(app, argv)
}

isShellIntegrationSupported (): boolean {
Expand Down
3 changes: 2 additions & 1 deletion tabby-linkifier/package.json
Expand Up @@ -17,6 +17,7 @@
"author": "Eugene Pankov",
"license": "MIT",
"devDependencies": {
"untildify": "^4.0.0"
"untildify": "^4.0.0",
"xterm-addon-web-links": "^0.7.0"
}
}
55 changes: 23 additions & 32 deletions tabby-linkifier/src/decorator.ts
@@ -1,63 +1,54 @@
import { Inject, Injectable } from '@angular/core'
import { ConfigService, PlatformService, TranslateService } from 'tabby-core'
import { TerminalDecorator, BaseTerminalTabComponent } from 'tabby-terminal'

import { ConfigService, PlatformService } from 'tabby-core'
import { TerminalDecorator, BaseTerminalTabComponent, XTermFrontend } from 'tabby-terminal'
import { WebLinksAddon } from 'xterm-addon-web-links'
import { LinkHandler } from './api'

@Injectable()
export class LinkHighlighterDecorator extends TerminalDecorator {
constructor (
private config: ConfigService,
private platform: PlatformService,
private translate: TranslateService,
@Inject(LinkHandler) private handlers: LinkHandler[],
) {
super()
}

attach (tab: BaseTerminalTabComponent): void {
if (!(tab.frontend as any).xterm) {
// not hterm
if (!(tab.frontend instanceof XTermFrontend)) {
// not xterm
return
}

tab.frontend.xterm.options.linkHandler = {
activate: (event, uri) => {
if (!this.willHandleEvent(event)) {
return
}
this.platform.openExternal(uri)
},
}

for (const handler of this.handlers) {
const getLink = async uri => handler.convert(uri, tab)
const openLink = async uri => handler.handle(await getLink(uri), tab)

;(tab.frontend as any).xterm.registerLinkMatcher(
handler.regex,
(event: MouseEvent, uri: string) => {
const addon = new WebLinksAddon(
async (event, uri) => {
if (!this.willHandleEvent(event)) {
return
}
if (!await handler.verify(await handler.convert(uri, tab), tab)) {
return
}
openLink(uri)
},
{
priority: handler.priority,
validationCallback: async (uri: string, callback: (isValid: boolean) => void) => {
callback(await handler.verify(await handler.convert(uri, tab), tab))
},
willLinkActivate: (event: MouseEvent, uri: string) => {
if (event.button === 2) {
this.platform.popupContextMenu([
{
click: () => openLink(uri),
label: this.translate.instant('Open'),
},
{
click: async () => {
this.platform.setClipboard({ text: await getLink(uri) })
},
label: this.translate.instant('Copy'),
},
])
return false
}
return this.willHandleEvent(event)
},
}
urlRegex: handler.regex,
},
)

tab.frontend.xterm.loadAddon(addon)
}
}

Expand Down
5 changes: 5 additions & 0 deletions tabby-linkifier/yarn.lock
Expand Up @@ -6,3 +6,8 @@ untildify@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/untildify/-/untildify-4.0.0.tgz#2bc947b953652487e4600949fb091e3ae8cd919b"
integrity sha512-KK8xQ1mkzZeg9inewmFVDNkg3l5LUhoq9kN6iWYB/CC9YMG8HA+c1Q8HwDe6dEX7kErrEVNVBO3fWsVq5iDgtw==

xterm-addon-web-links@^0.7.0:
version "0.7.0"
resolved "https://registry.yarnpkg.com/xterm-addon-web-links/-/xterm-addon-web-links-0.7.0.tgz#dceac36170605f9db10a01d716bd83ee38f65c17"
integrity sha512-6PqoqzzPwaeSq22skzbvyboDvSnYk5teUYEoKBwMYvhbkwOQkemZccjWHT5FnNA8o1aInTc4PRYAl4jjPucCKA==
4 changes: 3 additions & 1 deletion tabby-ssh/package.json
Expand Up @@ -28,8 +28,10 @@
"strip-ansi": "^7.0.0"
},
"dependencies": {
"@luminati-io/socksv5": "^0.0.7",
"node-forge": "^1.3.1",
"run-script-os": "^1.1.3",
"@luminati-io/socksv5": "^0.0.7"
"tmp-promise": "^3.0.3"
},
"peerDependencies": {
"@angular/animations": "^9.1.9",
Expand Down
17 changes: 14 additions & 3 deletions tabby-ssh/src/services/ssh.service.ts
@@ -1,5 +1,9 @@
import * as shellQuote from 'shell-quote'
import * as net from 'net'
import * as fs from 'fs/promises'
import * as tmp from 'tmp-promise'
import * as sshpk from 'sshpk'
import * as forge from 'node-forge'
import socksv5 from '@luminati-io/socksv5'
import { Duplex } from 'stream'
import { Injectable } from '@angular/core'
Expand Down Expand Up @@ -45,11 +49,18 @@ export class SSHService {
return
}
const args = [await this.getWinSCPURI(session.profile, undefined, session.authUsername ?? undefined)]

let tmpFile: tmp.FileResult|null = null
if (session.activePrivateKey) {
args.push('/privatekey')
args.push(session.activePrivateKey)
tmpFile = await tmp.file()
const privateKey = await sshpk.parsePrivateKey(session.activePrivateKey, 'auto')/* .toString('putty') */
const forgePrivateKey = forge.pki.decryptRsaPrivateKey(privateKey.toString('pem'))
const ppk = forge.ssh.privateKeyToPutty(forgePrivateKey)
await fs.writeFile(tmpFile.path, ppk)
args.push(`/privatekey=${tmpFile.path}`)
}
this.platform.exec(path, args)
await this.platform.exec(path, args)
tmpFile?.cleanup()
}
}

Expand Down
45 changes: 45 additions & 0 deletions tabby-ssh/yarn.lock
Expand Up @@ -156,6 +156,18 @@ getpass@^0.1.1:
once "^1.3.0"
path-is-absolute "^1.0.0"

glob@^7.1.3:
version "7.2.3"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b"
integrity sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==
dependencies:
fs.realpath "^1.0.0"
inflight "^1.0.4"
inherits "2"
minimatch "^3.1.1"
once "^1.3.0"
path-is-absolute "^1.0.0"

inflight@^1.0.4:
version "1.0.6"
resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9"
Expand Down Expand Up @@ -195,6 +207,18 @@ minimatch@^3.0.4:
dependencies:
brace-expansion "^1.1.7"

minimatch@^3.1.1:
version "3.1.2"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b"
integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==
dependencies:
brace-expansion "^1.1.7"

node-forge@^1.3.1:
version "1.3.1"
resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-1.3.1.tgz#be8da2af243b2417d5f646a770663a92b7e9ded3"
integrity sha512-dPEtOeMvF9VMcYV/1Wb8CPoVAXtp6MKMlcbAt4ddqmGqUJ6fQZFXkNZNkNlfevtNkGtaSoXf/vNNNSvgrdXwtA==

once@^1.3.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
Expand All @@ -212,6 +236,13 @@ pkginfo@0.3.x:
resolved "https://registry.yarnpkg.com/pkginfo/-/pkginfo-0.3.1.tgz#5b29f6a81f70717142e09e765bbeab97b4f81e21"
integrity sha1-Wyn2qB9wcXFC4J52W76rl7T4HiE=

rimraf@^3.0.0:
version "3.0.2"
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a"
integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==
dependencies:
glob "^7.1.3"

run-script-os@^1.1.3:
version "1.1.6"
resolved "https://registry.yarnpkg.com/run-script-os/-/run-script-os-1.1.6.tgz#8b0177fb1b54c99a670f95c7fdc54f18b9c72347"
Expand Down Expand Up @@ -253,6 +284,20 @@ strip-ansi@^7.0.0:
dependencies:
ansi-regex "^6.0.0"

tmp-promise@^3.0.3:
version "3.0.3"
resolved "https://registry.yarnpkg.com/tmp-promise/-/tmp-promise-3.0.3.tgz#60a1a1cc98c988674fcbfd23b6e3367bdeac4ce7"
integrity sha512-RwM7MoPojPxsOBYnyd2hy0bxtIlVrihNs9pj5SUvY8Zz1sQcQG2tG1hSr8PDxfgEB8RNKDhqbIlroIarSNDNsQ==
dependencies:
tmp "^0.2.0"

tmp@^0.2.0:
version "0.2.1"
resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.2.1.tgz#8457fc3037dcf4719c251367a1af6500ee1ccf14"
integrity sha512-76SUhtfqR2Ijn+xllcI5P1oyannHNHByD80W1q447gU3mp9G9PSpGdWmjUOHRDPiHYacIk66W7ubDTuPF3BEtQ==
dependencies:
rimraf "^3.0.0"

tweetnacl@^0.14.3, tweetnacl@~0.14.0:
version "0.14.5"
resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64"
Expand Down
3 changes: 2 additions & 1 deletion tabby-terminal/package.json
Expand Up @@ -26,7 +26,8 @@
"ngx-colors": "^3.0.4",
"ps-node": "^0.1.6",
"runes": "^0.4.2",
"xterm": "npm:@tabby-gang/xterm@^4.19.0-beta.4",
"xterm": "^5.0.0",
"xterm-addon-canvas": "^0.2.0",
"xterm-addon-fit": "^0.6.0-beta.8",
"xterm-addon-image": "^0.1.0",
"xterm-addon-ligatures": "^0.6.0-beta.14",
Expand Down