@theia/remote 1.43.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/README.md +61 -0
  2. package/lib/electron-browser/remote-electron-file-dialog-service.d.ts +14 -0
  3. package/lib/electron-browser/remote-electron-file-dialog-service.d.ts.map +1 -0
  4. package/lib/electron-browser/remote-electron-file-dialog-service.js +58 -0
  5. package/lib/electron-browser/remote-electron-file-dialog-service.js.map +1 -0
  6. package/lib/electron-browser/remote-frontend-contribution.d.ts +26 -0
  7. package/lib/electron-browser/remote-frontend-contribution.d.ts.map +1 -0
  8. package/lib/electron-browser/remote-frontend-contribution.js +165 -0
  9. package/lib/electron-browser/remote-frontend-contribution.js.map +1 -0
  10. package/lib/electron-browser/remote-frontend-module.d.ts +4 -0
  11. package/lib/electron-browser/remote-frontend-module.d.ts.map +1 -0
  12. package/lib/electron-browser/remote-frontend-module.js +43 -0
  13. package/lib/electron-browser/remote-frontend-module.js.map +1 -0
  14. package/lib/electron-browser/remote-preferences.d.ts +11 -0
  15. package/lib/electron-browser/remote-preferences.d.ts.map +1 -0
  16. package/lib/electron-browser/remote-preferences.js +49 -0
  17. package/lib/electron-browser/remote-preferences.js.map +1 -0
  18. package/lib/electron-browser/remote-registry-contribution.d.ts +19 -0
  19. package/lib/electron-browser/remote-registry-contribution.d.ts.map +1 -0
  20. package/lib/electron-browser/remote-registry-contribution.js +75 -0
  21. package/lib/electron-browser/remote-registry-contribution.js.map +1 -0
  22. package/lib/electron-browser/remote-service.d.ts +6 -0
  23. package/lib/electron-browser/remote-service.d.ts.map +1 -0
  24. package/lib/electron-browser/remote-service.js +38 -0
  25. package/lib/electron-browser/remote-service.js.map +1 -0
  26. package/lib/electron-browser/remote-ssh-contribution.d.ts +18 -0
  27. package/lib/electron-browser/remote-ssh-contribution.d.ts.map +1 -0
  28. package/lib/electron-browser/remote-ssh-contribution.js +118 -0
  29. package/lib/electron-browser/remote-ssh-contribution.js.map +1 -0
  30. package/lib/electron-common/remote-ssh-connection-provider.d.ts +11 -0
  31. package/lib/electron-common/remote-ssh-connection-provider.d.ts.map +1 -0
  32. package/lib/electron-common/remote-ssh-connection-provider.js +21 -0
  33. package/lib/electron-common/remote-ssh-connection-provider.js.map +1 -0
  34. package/lib/electron-common/remote-status-service.d.ts +15 -0
  35. package/lib/electron-common/remote-status-service.d.ts.map +1 -0
  36. package/lib/electron-common/remote-status-service.js +21 -0
  37. package/lib/electron-common/remote-status-service.js.map +1 -0
  38. package/lib/electron-node/backend-remote-service-impl.d.ts +12 -0
  39. package/lib/electron-node/backend-remote-service-impl.d.ts.map +1 -0
  40. package/lib/electron-node/backend-remote-service-impl.js +51 -0
  41. package/lib/electron-node/backend-remote-service-impl.js.map +1 -0
  42. package/lib/electron-node/remote-backend-module.d.ts +5 -0
  43. package/lib/electron-node/remote-backend-module.d.ts.map +1 -0
  44. package/lib/electron-node/remote-backend-module.js +75 -0
  45. package/lib/electron-node/remote-backend-module.js.map +1 -0
  46. package/lib/electron-node/remote-connection-service.d.ts +15 -0
  47. package/lib/electron-node/remote-connection-service.d.ts.map +1 -0
  48. package/lib/electron-node/remote-connection-service.js +66 -0
  49. package/lib/electron-node/remote-connection-service.js.map +1 -0
  50. package/lib/electron-node/remote-connection-socket-provider.d.ts +9 -0
  51. package/lib/electron-node/remote-connection-socket-provider.d.ts.map +1 -0
  52. package/lib/electron-node/remote-connection-socket-provider.js +38 -0
  53. package/lib/electron-node/remote-connection-socket-provider.js.map +1 -0
  54. package/lib/electron-node/remote-proxy-server-provider.d.ts +6 -0
  55. package/lib/electron-node/remote-proxy-server-provider.d.ts.map +1 -0
  56. package/lib/electron-node/remote-proxy-server-provider.js +44 -0
  57. package/lib/electron-node/remote-proxy-server-provider.js.map +1 -0
  58. package/lib/electron-node/remote-status-service.d.ts +7 -0
  59. package/lib/electron-node/remote-status-service.d.ts.map +1 -0
  60. package/lib/electron-node/remote-status-service.js +55 -0
  61. package/lib/electron-node/remote-status-service.js.map +1 -0
  62. package/lib/electron-node/remote-types.d.ts +35 -0
  63. package/lib/electron-node/remote-types.d.ts.map +1 -0
  64. package/lib/electron-node/remote-types.js +18 -0
  65. package/lib/electron-node/remote-types.js.map +1 -0
  66. package/lib/electron-node/setup/app-native-dependency-contribution.d.ts +8 -0
  67. package/lib/electron-node/setup/app-native-dependency-contribution.d.ts.map +1 -0
  68. package/lib/electron-node/setup/app-native-dependency-contribution.js +58 -0
  69. package/lib/electron-node/setup/app-native-dependency-contribution.js.map +1 -0
  70. package/lib/electron-node/setup/main-copy-contribution.d.ts +5 -0
  71. package/lib/electron-node/setup/main-copy-contribution.d.ts.map +1 -0
  72. package/lib/electron-node/setup/main-copy-contribution.js +38 -0
  73. package/lib/electron-node/setup/main-copy-contribution.js.map +1 -0
  74. package/lib/electron-node/setup/remote-copy-contribution.d.ts +29 -0
  75. package/lib/electron-node/setup/remote-copy-contribution.d.ts.map +1 -0
  76. package/lib/electron-node/setup/remote-copy-contribution.js +79 -0
  77. package/lib/electron-node/setup/remote-copy-contribution.js.map +1 -0
  78. package/lib/electron-node/setup/remote-copy-service.d.ts +19 -0
  79. package/lib/electron-node/setup/remote-copy-service.d.ts.map +1 -0
  80. package/lib/electron-node/setup/remote-copy-service.js +127 -0
  81. package/lib/electron-node/setup/remote-copy-service.js.map +1 -0
  82. package/lib/electron-node/setup/remote-native-dependency-contribution.d.ts +35 -0
  83. package/lib/electron-node/setup/remote-native-dependency-contribution.d.ts.map +1 -0
  84. package/lib/electron-node/setup/remote-native-dependency-contribution.js +35 -0
  85. package/lib/electron-node/setup/remote-native-dependency-contribution.js.map +1 -0
  86. package/lib/electron-node/setup/remote-native-dependency-service.d.ts +24 -0
  87. package/lib/electron-node/setup/remote-native-dependency-service.d.ts.map +1 -0
  88. package/lib/electron-node/setup/remote-native-dependency-service.js +119 -0
  89. package/lib/electron-node/setup/remote-native-dependency-service.js.map +1 -0
  90. package/lib/electron-node/setup/remote-node-setup-service.d.ts +23 -0
  91. package/lib/electron-node/setup/remote-node-setup-service.d.ts.map +1 -0
  92. package/lib/electron-node/setup/remote-node-setup-service.js +133 -0
  93. package/lib/electron-node/setup/remote-node-setup-service.js.map +1 -0
  94. package/lib/electron-node/setup/remote-setup-script-service.d.ts +41 -0
  95. package/lib/electron-node/setup/remote-setup-script-service.d.ts.map +1 -0
  96. package/lib/electron-node/setup/remote-setup-script-service.js +133 -0
  97. package/lib/electron-node/setup/remote-setup-script-service.js.map +1 -0
  98. package/lib/electron-node/setup/remote-setup-service.d.ts +29 -0
  99. package/lib/electron-node/setup/remote-setup-service.d.ts.map +1 -0
  100. package/lib/electron-node/setup/remote-setup-service.js +199 -0
  101. package/lib/electron-node/setup/remote-setup-service.js.map +1 -0
  102. package/lib/electron-node/ssh/remote-ssh-connection-provider.d.ts +56 -0
  103. package/lib/electron-node/ssh/remote-ssh-connection-provider.d.ts.map +1 -0
  104. package/lib/electron-node/ssh/remote-ssh-connection-provider.js +343 -0
  105. package/lib/electron-node/ssh/remote-ssh-connection-provider.js.map +1 -0
  106. package/lib/electron-node/ssh/ssh-identity-file-collector.d.ts +13 -0
  107. package/lib/electron-node/ssh/ssh-identity-file-collector.d.ts.map +1 -0
  108. package/lib/electron-node/ssh/ssh-identity-file-collector.js +132 -0
  109. package/lib/electron-node/ssh/ssh-identity-file-collector.js.map +1 -0
  110. package/lib/package.spec.d.ts +1 -0
  111. package/lib/package.spec.d.ts.map +1 -0
  112. package/lib/package.spec.js +26 -0
  113. package/lib/package.spec.js.map +1 -0
  114. package/package.json +67 -0
  115. package/src/electron-browser/remote-electron-file-dialog-service.ts +47 -0
  116. package/src/electron-browser/remote-frontend-contribution.ts +145 -0
  117. package/src/electron-browser/remote-frontend-module.ts +49 -0
  118. package/src/electron-browser/remote-preferences.ts +62 -0
  119. package/src/electron-browser/remote-registry-contribution.ts +70 -0
  120. package/src/electron-browser/remote-service.ts +31 -0
  121. package/src/electron-browser/remote-ssh-contribution.ts +102 -0
  122. package/src/electron-common/remote-ssh-connection-provider.ts +29 -0
  123. package/src/electron-common/remote-status-service.ts +35 -0
  124. package/src/electron-node/backend-remote-service-impl.ts +45 -0
  125. package/src/electron-node/remote-backend-module.ts +80 -0
  126. package/src/electron-node/remote-connection-service.ts +55 -0
  127. package/src/electron-node/remote-connection-socket-provider.ts +34 -0
  128. package/src/electron-node/remote-proxy-server-provider.ts +37 -0
  129. package/src/electron-node/remote-status-service.ts +41 -0
  130. package/src/electron-node/remote-types.ts +56 -0
  131. package/src/electron-node/setup/app-native-dependency-contribution.ts +48 -0
  132. package/src/electron-node/setup/main-copy-contribution.ts +28 -0
  133. package/src/electron-node/setup/remote-copy-contribution.ts +90 -0
  134. package/src/electron-node/setup/remote-copy-service.ts +114 -0
  135. package/src/electron-node/setup/remote-native-dependency-contribution.ts +63 -0
  136. package/src/electron-node/setup/remote-native-dependency-service.ts +111 -0
  137. package/src/electron-node/setup/remote-node-setup-service.ts +123 -0
  138. package/src/electron-node/setup/remote-setup-script-service.ts +146 -0
  139. package/src/electron-node/setup/remote-setup-service.ts +197 -0
  140. package/src/electron-node/ssh/remote-ssh-connection-provider.ts +356 -0
  141. package/src/electron-node/ssh/ssh-identity-file-collector.ts +137 -0
  142. package/src/package.spec.ts +29 -0
@@ -0,0 +1,199 @@
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2023 TypeFox and others.
4
+ //
5
+ // This program and the accompanying materials are made available under the
6
+ // terms of the Eclipse Public License v. 2.0 which is available at
7
+ // http://www.eclipse.org/legal/epl-2.0.
8
+ //
9
+ // This Source Code may also be made available under the following Secondary
10
+ // Licenses when the conditions for such availability set forth in the Eclipse
11
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
+ // with the GNU Classpath Exception which is available at
13
+ // https://www.gnu.org/software/classpath/license.html.
14
+ //
15
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
16
+ // *****************************************************************************
17
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
18
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
19
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
20
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
21
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
22
+ };
23
+ var __metadata = (this && this.__metadata) || function (k, v) {
24
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
25
+ };
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.RemoteSetupService = void 0;
28
+ const inversify_1 = require("@theia/core/shared/inversify");
29
+ const application_package_1 = require("@theia/core/shared/@theia/application-package");
30
+ const remote_copy_service_1 = require("./remote-copy-service");
31
+ const remote_native_dependency_service_1 = require("./remote-native-dependency-service");
32
+ const core_1 = require("@theia/core");
33
+ const remote_node_setup_service_1 = require("./remote-node-setup-service");
34
+ const remote_setup_script_service_1 = require("./remote-setup-script-service");
35
+ let RemoteSetupService = class RemoteSetupService {
36
+ async setup(options) {
37
+ const { connection, report, nodeDownloadTemplate } = options;
38
+ report('Identifying remote system...');
39
+ // 1. Identify remote platform
40
+ const platform = await this.detectRemotePlatform(connection);
41
+ // 2. Setup home directory
42
+ const remoteHome = await this.getRemoteHomeDirectory(connection, platform);
43
+ const applicationDirectory = this.scriptService.joinPath(platform, remoteHome, `.${this.getRemoteAppName()}`);
44
+ await this.mkdirRemote(connection, platform, applicationDirectory);
45
+ // 3. Download+copy node for that platform
46
+ const nodeFileName = this.nodeSetupService.getNodeFileName(platform);
47
+ const nodeDirName = this.nodeSetupService.getNodeDirectoryName(platform);
48
+ const remoteNodeDirectory = this.scriptService.joinPath(platform, applicationDirectory, nodeDirName);
49
+ const nodeDirExists = await this.dirExistsRemote(connection, remoteNodeDirectory);
50
+ if (!nodeDirExists) {
51
+ report('Downloading and installing Node.js on remote...');
52
+ // Download the binaries locally and move it via SSH
53
+ const nodeArchive = await this.nodeSetupService.downloadNode(platform, nodeDownloadTemplate);
54
+ const remoteNodeZip = this.scriptService.joinPath(platform, applicationDirectory, nodeFileName);
55
+ await connection.copy(nodeArchive, remoteNodeZip);
56
+ await this.unzipRemote(connection, platform, remoteNodeZip, applicationDirectory);
57
+ }
58
+ // 4. Copy backend to remote system
59
+ const libDir = this.scriptService.joinPath(platform, applicationDirectory, 'lib');
60
+ const libDirExists = await this.dirExistsRemote(connection, libDir);
61
+ if (!libDirExists) {
62
+ report('Installing application on remote...');
63
+ const applicationZipFile = this.scriptService.joinPath(platform, applicationDirectory, `${this.getRemoteAppName()}.tar`);
64
+ await this.copyService.copyToRemote(connection, platform, applicationZipFile);
65
+ await this.unzipRemote(connection, platform, applicationZipFile, applicationDirectory);
66
+ }
67
+ // 5. start remote backend
68
+ report('Starting application on remote...');
69
+ const port = await this.startApplication(connection, platform, applicationDirectory, remoteNodeDirectory);
70
+ connection.remotePort = port;
71
+ }
72
+ async startApplication(connection, platform, remotePath, nodeDir) {
73
+ const nodeExecutable = this.scriptService.joinPath(platform, nodeDir, ...(platform.os === core_1.OS.Type.Windows ? ['node.exe'] : ['bin', 'node']));
74
+ const mainJsFile = this.scriptService.joinPath(platform, remotePath, 'lib', 'backend', 'main.js');
75
+ const localAddressRegex = /listening on http:\/\/127.0.0.1:(\d+)/;
76
+ let prefix = '';
77
+ if (platform.os === core_1.OS.Type.Windows) {
78
+ // We might to switch to PowerShell beforehand on Windows
79
+ prefix = this.scriptService.exec(platform) + ' ';
80
+ }
81
+ // Change to the remote application path and start a node process with the copied main.js file
82
+ // This way, our current working directory is set as expected
83
+ const result = await connection.execPartial(`${prefix}cd "${remotePath}";${nodeExecutable}`, stdout => localAddressRegex.test(stdout), [mainJsFile, '--hostname=127.0.0.1', '--port=0', '--remote']);
84
+ const match = localAddressRegex.exec(result.stdout);
85
+ if (!match) {
86
+ throw new Error('Could not start remote system: ' + result.stdout);
87
+ }
88
+ else {
89
+ return Number(match[1]);
90
+ }
91
+ }
92
+ async detectRemotePlatform(connection) {
93
+ const osResult = await connection.exec('uname -s');
94
+ let os;
95
+ if (osResult.stderr) {
96
+ // Only Windows systems return an error stream here
97
+ os = core_1.OS.Type.Windows;
98
+ }
99
+ else if (osResult.stdout) {
100
+ if (osResult.stdout.includes('windows32') || osResult.stdout.includes('MINGW64')) {
101
+ os = core_1.OS.Type.Windows;
102
+ }
103
+ else if (osResult.stdout.includes('Linux')) {
104
+ os = core_1.OS.Type.Linux;
105
+ }
106
+ else if (osResult.stdout.includes('Darwin')) {
107
+ os = core_1.OS.Type.OSX;
108
+ }
109
+ }
110
+ if (!os) {
111
+ throw new Error('Failed to identify remote system: ' + osResult.stdout + '\n' + osResult.stderr);
112
+ }
113
+ let arch;
114
+ if (os === core_1.OS.Type.Windows) {
115
+ const wmicResult = await connection.exec('wmic OS get OSArchitecture');
116
+ if (wmicResult.stdout.includes('64-bit')) {
117
+ arch = 'x64';
118
+ }
119
+ else if (wmicResult.stdout.includes('32-bit')) {
120
+ arch = 'x86';
121
+ }
122
+ }
123
+ else {
124
+ const archResult = (await connection.exec('uname -m')).stdout;
125
+ if (archResult.includes('x86_64')) {
126
+ arch = 'x64';
127
+ }
128
+ else if (archResult.match(/i\d83/)) { // i386, i483, i683
129
+ arch = 'x86';
130
+ }
131
+ else {
132
+ arch = archResult.trim();
133
+ }
134
+ }
135
+ if (!arch) {
136
+ throw new Error('Could not identify remote system architecture');
137
+ }
138
+ return {
139
+ os,
140
+ arch
141
+ };
142
+ }
143
+ async getRemoteHomeDirectory(connection, platform) {
144
+ const result = await connection.exec(this.scriptService.home(platform));
145
+ return result.stdout.trim();
146
+ }
147
+ getRemoteAppName() {
148
+ const appName = this.applicationPackage.pck.name || 'theia';
149
+ const appVersion = this.applicationPackage.pck.version || core_1.THEIA_VERSION;
150
+ return `${this.cleanupDirectoryName(`${appName}-${appVersion}`)}-remote`;
151
+ }
152
+ cleanupDirectoryName(name) {
153
+ return name.replace(/[@<>:"\\|?*]/g, '').replace(/\//g, '-');
154
+ }
155
+ async mkdirRemote(connection, platform, remotePath) {
156
+ const result = await connection.exec(this.scriptService.mkdir(platform, remotePath));
157
+ if (result.stderr) {
158
+ throw new Error('Failed to create directory: ' + result.stderr);
159
+ }
160
+ }
161
+ async dirExistsRemote(connection, remotePath) {
162
+ const cdResult = await connection.exec(`cd "${remotePath}"`);
163
+ return !Boolean(cdResult.stderr);
164
+ }
165
+ async unzipRemote(connection, platform, remoteFile, remoteDirectory) {
166
+ const result = await connection.exec(this.scriptService.unzip(platform, remoteFile, remoteDirectory));
167
+ if (result.stderr) {
168
+ throw new Error('Failed to unzip: ' + result.stderr);
169
+ }
170
+ }
171
+ async executeScriptRemote(connection, platform, script) {
172
+ return connection.exec(this.scriptService.exec(platform), [script]);
173
+ }
174
+ };
175
+ __decorate([
176
+ (0, inversify_1.inject)(remote_copy_service_1.RemoteCopyService),
177
+ __metadata("design:type", remote_copy_service_1.RemoteCopyService)
178
+ ], RemoteSetupService.prototype, "copyService", void 0);
179
+ __decorate([
180
+ (0, inversify_1.inject)(remote_native_dependency_service_1.RemoteNativeDependencyService),
181
+ __metadata("design:type", remote_native_dependency_service_1.RemoteNativeDependencyService)
182
+ ], RemoteSetupService.prototype, "nativeDependencyService", void 0);
183
+ __decorate([
184
+ (0, inversify_1.inject)(remote_node_setup_service_1.RemoteNodeSetupService),
185
+ __metadata("design:type", remote_node_setup_service_1.RemoteNodeSetupService)
186
+ ], RemoteSetupService.prototype, "nodeSetupService", void 0);
187
+ __decorate([
188
+ (0, inversify_1.inject)(remote_setup_script_service_1.RemoteSetupScriptService),
189
+ __metadata("design:type", remote_setup_script_service_1.RemoteSetupScriptService)
190
+ ], RemoteSetupService.prototype, "scriptService", void 0);
191
+ __decorate([
192
+ (0, inversify_1.inject)(application_package_1.ApplicationPackage),
193
+ __metadata("design:type", application_package_1.ApplicationPackage)
194
+ ], RemoteSetupService.prototype, "applicationPackage", void 0);
195
+ RemoteSetupService = __decorate([
196
+ (0, inversify_1.injectable)()
197
+ ], RemoteSetupService);
198
+ exports.RemoteSetupService = RemoteSetupService;
199
+ //# sourceMappingURL=remote-setup-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remote-setup-service.js","sourceRoot":"","sources":["../../../src/electron-node/setup/remote-setup-service.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;;;;;;;;;;AAEhF,4DAAkE;AAElE,uFAAmF;AACnF,+DAA0D;AAC1D,yFAAmF;AACnF,sCAAgD;AAChD,2EAAqE;AACrE,+EAAyE;AASzE,IAAa,kBAAkB,GAA/B,MAAa,kBAAkB;IAiB3B,KAAK,CAAC,KAAK,CAAC,OAA2B;QACnC,MAAM,EACF,UAAU,EACV,MAAM,EACN,oBAAoB,EACvB,GAAG,OAAO,CAAC;QACZ,MAAM,CAAC,8BAA8B,CAAC,CAAC;QACvC,8BAA8B;QAC9B,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC;QAC7D,0BAA0B;QAC1B,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,sBAAsB,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QAC3E,MAAM,oBAAoB,GAAG,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,QAAQ,EAAE,UAAU,EAAE,IAAI,IAAI,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;QAC9G,MAAM,IAAI,CAAC,WAAW,CAAC,UAAU,EAAE,QAAQ,EAAE,oBAAoB,CAAC,CAAC;QACnE,0CAA0C;QA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AAE;YACf,MAAM,IAAI,KAAK,CAAC,mBAAmB,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;SACxD;IACL,CAAC;IAES,KAAK,CAAC,mBAAmB,CAAC,UAA4B,EAAE,QAAwB,EAAE,MAAc;QACtG,OAAO,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IACxE,CAAC;CACJ,CAAA;AAjKG;IADC,IAAA,kBAAM,EAAC,uCAAiB,CAAC;8BACM,uCAAiB;uDAAC;AAGlD;IADC,IAAA,kBAAM,EAAC,gEAA6B,CAAC;8BACM,gEAA6B;mEAAC;AAG1E;IADC,IAAA,kBAAM,EAAC,kDAAsB,CAAC;8BACM,kDAAsB;4DAAC;AAG5D;IADC,IAAA,kBAAM,EAAC,sDAAwB,CAAC;8BACC,sDAAwB;yDAAC;AAG3D;IADC,IAAA,kBAAM,EAAC,wCAAkB,CAAC;8BACY,wCAAkB;8DAAC;AAfjD,kBAAkB;IAD9B,IAAA,sBAAU,GAAE;GACA,kBAAkB,CAoK9B;AApKY,gDAAkB"}
@@ -0,0 +1,56 @@
1
+ /// <reference types="node" />
2
+ import * as ssh2 from 'ssh2';
3
+ import * as net from 'net';
4
+ import SftpClient = require('ssh2-sftp-client');
5
+ import { Event, MessageService, QuickInputService } from '@theia/core';
6
+ import { RemoteSSHConnectionProvider, RemoteSSHConnectionProviderOptions } from '../../electron-common/remote-ssh-connection-provider';
7
+ import { RemoteConnectionService } from '../remote-connection-service';
8
+ import { RemoteProxyServerProvider } from '../remote-proxy-server-provider';
9
+ import { RemoteConnection, RemoteExecOptions, RemoteExecResult, RemoteExecTester } from '../remote-types';
10
+ import { SSHIdentityFileCollector, SSHKey } from './ssh-identity-file-collector';
11
+ import { RemoteSetupService } from '../setup/remote-setup-service';
12
+ export declare class RemoteSSHConnectionProviderImpl implements RemoteSSHConnectionProvider {
13
+ protected readonly remoteConnectionService: RemoteConnectionService;
14
+ protected readonly serverProvider: RemoteProxyServerProvider;
15
+ protected readonly identityFileCollector: SSHIdentityFileCollector;
16
+ protected readonly remoteSetup: RemoteSetupService;
17
+ protected readonly quickInputService: QuickInputService;
18
+ protected readonly messageService: MessageService;
19
+ protected passwordRetryCount: number;
20
+ protected passphraseRetryCount: number;
21
+ establishConnection(options: RemoteSSHConnectionProviderOptions): Promise<string>;
22
+ establishSSHConnection(host: string, user: string): Promise<RemoteSSHConnection>;
23
+ /**
24
+ * Sometimes, ssh2.exec will not execute and retrieve any data right after the `ready` event fired.
25
+ * In this method, we just perform `echo hello` in a loop to ensure that the connection is really ready.
26
+ * See also https://github.com/mscdex/ssh2/issues/48
27
+ */
28
+ protected testConnection(connection: RemoteSSHConnection): Promise<void>;
29
+ protected getAuthHandler(user: string, host: string, identityKeys: SSHKey[]): ssh2.AuthHandlerMiddleware;
30
+ }
31
+ export interface RemoteSSHConnectionOptions {
32
+ id: string;
33
+ name: string;
34
+ type: string;
35
+ client: ssh2.Client;
36
+ }
37
+ export declare class RemoteSSHConnection implements RemoteConnection {
38
+ id: string;
39
+ name: string;
40
+ type: string;
41
+ client: ssh2.Client;
42
+ localPort: number;
43
+ remotePort: number;
44
+ private sftpClientPromise;
45
+ private readonly onDidDisconnectEmitter;
46
+ get onDidDisconnect(): Event<void>;
47
+ constructor(options: RemoteSSHConnectionOptions);
48
+ protected setupSftpClient(): Promise<SftpClient>;
49
+ forwardOut(socket: net.Socket): void;
50
+ copy(localPath: string, remotePath: string): Promise<void>;
51
+ exec(cmd: string, args?: string[], options?: RemoteExecOptions): Promise<RemoteExecResult>;
52
+ execPartial(cmd: string, tester: RemoteExecTester, args?: string[], options?: RemoteExecOptions): Promise<RemoteExecResult>;
53
+ protected buildCmd(cmd: string, args?: string[]): string;
54
+ dispose(): void;
55
+ }
56
+ //# sourceMappingURL=remote-ssh-connection-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remote-ssh-connection-prov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CAAC,EAAE,MAAM,EAAE,EAAE,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IA+B/H,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM;IAMxD,OAAO,IAAI,IAAI;CAKlB"}
@@ -0,0 +1,343 @@
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2023 TypeFox and others.
4
+ //
5
+ // This program and the accompanying materials are made available under the
6
+ // terms of the Eclipse Public License v. 2.0 which is available at
7
+ // http://www.eclipse.org/legal/epl-2.0.
8
+ //
9
+ // This Source Code may also be made available under the following Secondary
10
+ // Licenses when the conditions for such availability set forth in the Eclipse
11
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
+ // with the GNU Classpath Exception which is available at
13
+ // https://www.gnu.org/software/classpath/license.html.
14
+ //
15
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
16
+ // *****************************************************************************
17
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
18
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
19
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
20
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
21
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
22
+ };
23
+ var __metadata = (this && this.__metadata) || function (k, v) {
24
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
25
+ };
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.RemoteSSHConnection = exports.RemoteSSHConnectionProviderImpl = void 0;
28
+ const ssh2 = require("ssh2");
29
+ const fs = require("@theia/core/shared/fs-extra");
30
+ const SftpClient = require("ssh2-sftp-client");
31
+ const core_1 = require("@theia/core");
32
+ const inversify_1 = require("@theia/core/shared/inversify");
33
+ const remote_connection_service_1 = require("../remote-connection-service");
34
+ const remote_proxy_server_provider_1 = require("../remote-proxy-server-provider");
35
+ const promise_util_1 = require("@theia/core/lib/common/promise-util");
36
+ const ssh_identity_file_collector_1 = require("./ssh-identity-file-collector");
37
+ const remote_setup_service_1 = require("../setup/remote-setup-service");
38
+ const uuid_1 = require("uuid");
39
+ let RemoteSSHConnectionProviderImpl = class RemoteSSHConnectionProviderImpl {
40
+ constructor() {
41
+ this.passwordRetryCount = 3;
42
+ this.passphraseRetryCount = 3;
43
+ }
44
+ async establishConnection(options) {
45
+ const progress = await this.messageService.showProgress({
46
+ text: 'Remote SSH'
47
+ });
48
+ const report = message => progress.report({ message });
49
+ report('Connecting to remote system...');
50
+ try {
51
+ const remote = await this.establishSSHConnection(options.host, options.user);
52
+ await this.remoteSetup.setup({
53
+ connection: remote,
54
+ report,
55
+ nodeDownloadTemplate: options.nodeDownloadTemplate
56
+ });
57
+ const registration = this.remoteConnectionService.register(remote);
58
+ const server = await this.serverProvider.getProxyServer(socket => {
59
+ remote.forwardOut(socket);
60
+ });
61
+ remote.onDidDisconnect(() => {
62
+ server.close();
63
+ registration.dispose();
64
+ });
65
+ const localPort = server.address().port;
66
+ remote.localPort = localPort;
67
+ return localPort.toString();
68
+ }
69
+ finally {
70
+ progress.cancel();
71
+ }
72
+ }
73
+ async establishSSHConnection(host, user) {
74
+ const deferred = new promise_util_1.Deferred();
75
+ const sshClient = new ssh2.Client();
76
+ const identityFiles = await this.identityFileCollector.gatherIdentityFiles();
77
+ const sshAuthHandler = this.getAuthHandler(user, host, identityFiles);
78
+ sshClient
79
+ .on('ready', async () => {
80
+ const connection = new RemoteSSHConnection({
81
+ client: sshClient,
82
+ id: (0, uuid_1.v4)(),
83
+ name: host,
84
+ type: 'SSH'
85
+ });
86
+ try {
87
+ await this.testConnection(connection);
88
+ deferred.resolve(connection);
89
+ }
90
+ catch (err) {
91
+ deferred.reject(err);
92
+ }
93
+ }).on('end', () => {
94
+ console.log(`Ended remote connection to host '${user}@${host}'`);
95
+ }).on('error', err => {
96
+ deferred.reject(err);
97
+ }).connect({
98
+ host: host,
99
+ username: user,
100
+ authHandler: (methodsLeft, successes, callback) => (sshAuthHandler(methodsLeft, successes, callback), undefined)
101
+ });
102
+ return deferred.promise;
103
+ }
104
+ /**
105
+ * Sometimes, ssh2.exec will not execute and retrieve any data right after the `ready` event fired.
106
+ * In this method, we just perform `echo hello` in a loop to ensure that the connection is really ready.
107
+ * See also https://github.com/mscdex/ssh2/issues/48
108
+ */
109
+ async testConnection(connection) {
110
+ for (let i = 0; i < 100; i++) {
111
+ const result = await connection.exec('echo hello');
112
+ if (result.stdout.includes('hello')) {
113
+ return;
114
+ }
115
+ await (0, promise_util_1.timeout)(50);
116
+ }
117
+ throw new Error('SSH connection failed testing. Could not execute "echo"');
118
+ }
119
+ getAuthHandler(user, host, identityKeys) {
120
+ let passwordRetryCount = this.passwordRetryCount;
121
+ let keyboardRetryCount = this.passphraseRetryCount;
122
+ // `false` is a valid return value, indicating that the authentication has failed
123
+ const END_AUTH = false;
124
+ // `null` indicates that we just want to continue with the next auth type
125
+ // eslint-disable-next-line no-null/no-null
126
+ const NEXT_AUTH = null;
127
+ return async (methodsLeft, _partialSuccess, callback) => {
128
+ if (!methodsLeft) {
129
+ return callback({
130
+ type: 'none',
131
+ username: user,
132
+ });
133
+ }
134
+ if (methodsLeft && methodsLeft.includes('publickey') && identityKeys.length) {
135
+ const identityKey = identityKeys.shift();
136
+ if (identityKey.isPrivate) {
137
+ return callback({
138
+ type: 'publickey',
139
+ username: user,
140
+ key: identityKey.parsedKey
141
+ });
142
+ }
143
+ if (!await fs.pathExists(identityKey.filename)) {
144
+ // Try next identity file
145
+ return callback(NEXT_AUTH);
146
+ }
147
+ const keyBuffer = await fs.promises.readFile(identityKey.filename);
148
+ let result = ssh2.utils.parseKey(keyBuffer); // First try without passphrase
149
+ if (result instanceof Error && result.message.match(/no passphrase given/)) {
150
+ let passphraseRetryCount = this.passphraseRetryCount;
151
+ while (result instanceof Error && passphraseRetryCount > 0) {
152
+ const passphrase = await this.quickInputService.input({
153
+ title: `Enter passphrase for ${identityKey.filename}`,
154
+ password: true
155
+ });
156
+ if (!passphrase) {
157
+ break;
158
+ }
159
+ result = ssh2.utils.parseKey(keyBuffer, passphrase);
160
+ passphraseRetryCount--;
161
+ }
162
+ }
163
+ if (!result || result instanceof Error) {
164
+ // Try next identity file
165
+ return callback(NEXT_AUTH);
166
+ }
167
+ const key = Array.isArray(result) ? result[0] : result;
168
+ return callback({
169
+ type: 'publickey',
170
+ username: user,
171
+ key
172
+ });
173
+ }
174
+ if (methodsLeft && methodsLeft.includes('password') && passwordRetryCount > 0) {
175
+ const password = await this.quickInputService.input({
176
+ title: `Enter password for ${user}@${host}`,
177
+ password: true
178
+ });
179
+ passwordRetryCount--;
180
+ return callback(password
181
+ ? {
182
+ type: 'password',
183
+ username: user,
184
+ password
185
+ }
186
+ : END_AUTH);
187
+ }
188
+ if (methodsLeft && methodsLeft.includes('keyboard-interactive') && keyboardRetryCount > 0) {
189
+ return callback({
190
+ type: 'keyboard-interactive',
191
+ username: user,
192
+ prompt: async (_name, _instructions, _instructionsLang, prompts, finish) => {
193
+ const responses = [];
194
+ for (const prompt of prompts) {
195
+ const response = await this.quickInputService.input({
196
+ title: `(${user}@${host}) ${prompt.prompt}`,
197
+ password: !prompt.echo
198
+ });
199
+ if (response === undefined) {
200
+ keyboardRetryCount = 0;
201
+ break;
202
+ }
203
+ responses.push(response);
204
+ }
205
+ keyboardRetryCount--;
206
+ finish(responses);
207
+ }
208
+ });
209
+ }
210
+ callback(END_AUTH);
211
+ };
212
+ }
213
+ };
214
+ __decorate([
215
+ (0, inversify_1.inject)(remote_connection_service_1.RemoteConnectionService),
216
+ __metadata("design:type", remote_connection_service_1.RemoteConnectionService)
217
+ ], RemoteSSHConnectionProviderImpl.prototype, "remoteConnectionService", void 0);
218
+ __decorate([
219
+ (0, inversify_1.inject)(remote_proxy_server_provider_1.RemoteProxyServerProvider),
220
+ __metadata("design:type", remote_proxy_server_provider_1.RemoteProxyServerProvider)
221
+ ], RemoteSSHConnectionProviderImpl.prototype, "serverProvider", void 0);
222
+ __decorate([
223
+ (0, inversify_1.inject)(ssh_identity_file_collector_1.SSHIdentityFileCollector),
224
+ __metadata("design:type", ssh_identity_file_collector_1.SSHIdentityFileCollector)
225
+ ], RemoteSSHConnectionProviderImpl.prototype, "identityFileCollector", void 0);
226
+ __decorate([
227
+ (0, inversify_1.inject)(remote_setup_service_1.RemoteSetupService),
228
+ __metadata("design:type", remote_setup_service_1.RemoteSetupService)
229
+ ], RemoteSSHConnectionProviderImpl.prototype, "remoteSetup", void 0);
230
+ __decorate([
231
+ (0, inversify_1.inject)(core_1.QuickInputService),
232
+ __metadata("design:type", Object)
233
+ ], RemoteSSHConnectionProviderImpl.prototype, "quickInputService", void 0);
234
+ __decorate([
235
+ (0, inversify_1.inject)(core_1.MessageService),
236
+ __metadata("design:type", core_1.MessageService)
237
+ ], RemoteSSHConnectionProviderImpl.prototype, "messageService", void 0);
238
+ RemoteSSHConnectionProviderImpl = __decorate([
239
+ (0, inversify_1.injectable)()
240
+ ], RemoteSSHConnectionProviderImpl);
241
+ exports.RemoteSSHConnectionProviderImpl = RemoteSSHConnectionProviderImpl;
242
+ class RemoteSSHConnection {
243
+ constructor(options) {
244
+ this.localPort = 0;
245
+ this.remotePort = 0;
246
+ this.onDidDisconnectEmitter = new core_1.Emitter();
247
+ this.id = options.id;
248
+ this.type = options.type;
249
+ this.name = options.name;
250
+ this.client = options.client;
251
+ this.onDidDisconnect(() => this.dispose());
252
+ this.client.on('end', () => {
253
+ this.onDidDisconnectEmitter.fire();
254
+ });
255
+ this.sftpClientPromise = this.setupSftpClient();
256
+ }
257
+ get onDidDisconnect() {
258
+ return this.onDidDisconnectEmitter.event;
259
+ }
260
+ async setupSftpClient() {
261
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
262
+ const sftpClient = new SftpClient();
263
+ // A hack to set the internal ssh2 client of the sftp client
264
+ // That way, we don't have to create a second connection
265
+ sftpClient.client = this.client;
266
+ // Calling this function establishes the sftp connection on the ssh client
267
+ await sftpClient.getSftpChannel();
268
+ return sftpClient;
269
+ }
270
+ forwardOut(socket) {
271
+ this.client.forwardOut(socket.localAddress, socket.localPort, '127.0.0.1', this.remotePort, (err, stream) => {
272
+ if (err) {
273
+ console.debug('Proxy message rejected', err);
274
+ }
275
+ else {
276
+ stream.pipe(socket).pipe(stream);
277
+ }
278
+ });
279
+ }
280
+ async copy(localPath, remotePath) {
281
+ const sftpClient = await this.sftpClientPromise;
282
+ await sftpClient.put(localPath, remotePath);
283
+ }
284
+ exec(cmd, args, options = {}) {
285
+ const deferred = new promise_util_1.Deferred();
286
+ cmd = this.buildCmd(cmd, args);
287
+ this.client.exec(cmd, options, (err, stream) => {
288
+ if (err) {
289
+ return deferred.reject(err);
290
+ }
291
+ let stdout = '';
292
+ let stderr = '';
293
+ stream.on('close', () => {
294
+ deferred.resolve({ stdout, stderr });
295
+ }).on('data', (data) => {
296
+ stdout += data.toString();
297
+ }).stderr.on('data', (data) => {
298
+ stderr += data.toString();
299
+ });
300
+ });
301
+ return deferred.promise;
302
+ }
303
+ execPartial(cmd, tester, args, options = {}) {
304
+ const deferred = new promise_util_1.Deferred();
305
+ cmd = this.buildCmd(cmd, args);
306
+ this.client.exec(cmd, {
307
+ ...options,
308
+ // Ensure that the process on the remote ends when the connection is closed
309
+ pty: true
310
+ }, (err, stream) => {
311
+ if (err) {
312
+ return deferred.reject(err);
313
+ }
314
+ // in pty mode we only have an stdout stream
315
+ // return stdout as stderr as well
316
+ let stdout = '';
317
+ stream.on('close', () => {
318
+ if (deferred.state === 'unresolved') {
319
+ deferred.resolve({ stdout, stderr: stdout });
320
+ }
321
+ }).on('data', (data) => {
322
+ if (deferred.state === 'unresolved') {
323
+ stdout += data.toString();
324
+ if (tester(stdout, stdout)) {
325
+ deferred.resolve({ stdout, stderr: stdout });
326
+ }
327
+ }
328
+ });
329
+ });
330
+ return deferred.promise;
331
+ }
332
+ buildCmd(cmd, args) {
333
+ const escapedArgs = (args === null || args === void 0 ? void 0 : args.map(arg => `"${arg.replace(/"/g, '\\"')}"`)) || [];
334
+ const fullCmd = cmd + (escapedArgs.length > 0 ? (' ' + escapedArgs.join(' ')) : '');
335
+ return fullCmd;
336
+ }
337
+ dispose() {
338
+ this.client.end();
339
+ this.client.destroy();
340
+ }
341
+ }
342
+ exports.RemoteSSHConnection = RemoteSSHConnection;
343
+ //# sourceMappingURL=remote-ssh-connection-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remote-ssh-connection-provider.js","sourceRoot":"","sources":["../../../src/electron-node/ssh/remote-ssh-connection-provider.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;;;;;;;;;;AAEhF,6BAA6B;AAE7B,kDAAkD;AAClD,+CAAgD;AAChD,sCAAgF;AAChF,4DAAkE;AAElE,4EAAuE;AACvE,kFAA4E;AAE5E,sEAAwE;AACxE,+EAAiF;AACjF,wEAAmE;AACnE,+BAA0B;AAG1B,IAAa,+BAA+B,GAA5C,MAAa,+BAA+B;IAA5C;QAoBc,uBAAkB,GAAG,CAAC,CAAC;QACvB,yBAAoB,GAAG,CAAC,CAAC;IAgLvC,CAAC;IA9KG,KAAK,CAAC,mBAAmB,CAAC,OAA2C;QACjE,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC;YACpD,IAAI,EAAE,YAAY;SACrB,CAAC,CAAC;QACH,MAAM,MAAM,GAAuB,OAAO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AC,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAqB,EAAE,EAAE;gBACpC,IAAI,QAAQ,CAAC,KAAK,KAAK,YAAY,EAAE;oBACjC,MAAM,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;oBAE1B,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE;wBACxB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;qBAChD;iBACJ;YACL,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;QACH,OAAO,QAAQ,CAAC,OAAO,CAAC;IAC5B,CAAC;IAES,QAAQ,CAAC,GAAW,EAAE,IAAe;QAC3C,MAAM,WAAW,GAAG,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,KAAI,EAAE,CAAC;QAC5E,MAAM,OAAO,GAAG,GAAG,GAAG,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACpF,OAAO,OAAO,CAAC;IACnB,CAAC;IAED,OAAO;QACH,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;QAClB,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;IAC1B,CAAC;CAEJ;AArHD,kDAqHC"}
@@ -0,0 +1,13 @@
1
+ import { ParsedKey } from 'ssh2';
2
+ export interface SSHKey {
3
+ filename: string;
4
+ parsedKey: ParsedKey;
5
+ fingerprint: string;
6
+ agentSupport?: boolean;
7
+ isPrivate?: boolean;
8
+ }
9
+ export declare class SSHIdentityFileCollector {
10
+ protected getDefaultIdentityFiles(): string[];
11
+ gatherIdentityFiles(sshAgentSock?: string): Promise<SSHKey[]>;
12
+ }
13
+ //# sourceMappingURL=ssh-identity-file-collector.d.ts.map