@theia/remote 1.52.0 → 1.53.0-next.55

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 (37) hide show
  1. package/README.md +61 -61
  2. package/lib/electron-node/setup/remote-setup-script-service.js +11 -11
  3. package/package.json +5 -5
  4. package/src/electron-browser/port-forwarding/port-forwading-contribution.ts +33 -33
  5. package/src/electron-browser/port-forwarding/port-forwarding-service.ts +92 -92
  6. package/src/electron-browser/port-forwarding/port-forwarding-widget.tsx +140 -140
  7. package/src/electron-browser/remote-electron-file-dialog-service.ts +47 -47
  8. package/src/electron-browser/remote-frontend-contribution.ts +143 -143
  9. package/src/electron-browser/remote-frontend-module.ts +68 -68
  10. package/src/electron-browser/remote-preferences.ts +62 -62
  11. package/src/electron-browser/remote-registry-contribution.ts +73 -73
  12. package/src/electron-browser/remote-service.ts +31 -31
  13. package/src/electron-browser/remote-ssh-contribution.ts +102 -102
  14. package/src/electron-browser/style/port-forwarding-widget.css +44 -44
  15. package/src/electron-common/remote-port-forwarding-provider.ts +30 -30
  16. package/src/electron-common/remote-ssh-connection-provider.ts +29 -29
  17. package/src/electron-common/remote-status-service.ts +35 -35
  18. package/src/electron-node/backend-remote-service-impl.ts +45 -45
  19. package/src/electron-node/remote-backend-module.ts +87 -87
  20. package/src/electron-node/remote-connection-service.ts +56 -56
  21. package/src/electron-node/remote-connection-socket-provider.ts +34 -34
  22. package/src/electron-node/remote-port-forwarding-provider.ts +66 -66
  23. package/src/electron-node/remote-proxy-server-provider.ts +37 -37
  24. package/src/electron-node/remote-status-service.ts +41 -41
  25. package/src/electron-node/remote-types.ts +64 -64
  26. package/src/electron-node/setup/app-native-dependency-contribution.ts +48 -48
  27. package/src/electron-node/setup/main-copy-contribution.ts +28 -28
  28. package/src/electron-node/setup/remote-copy-contribution.ts +74 -74
  29. package/src/electron-node/setup/remote-copy-service.ts +116 -116
  30. package/src/electron-node/setup/remote-native-dependency-contribution.ts +63 -63
  31. package/src/electron-node/setup/remote-native-dependency-service.ts +111 -111
  32. package/src/electron-node/setup/remote-node-setup-service.ts +123 -123
  33. package/src/electron-node/setup/remote-setup-script-service.ts +146 -146
  34. package/src/electron-node/setup/remote-setup-service.ts +220 -220
  35. package/src/electron-node/ssh/remote-ssh-connection-provider.ts +358 -358
  36. package/src/electron-node/ssh/ssh-identity-file-collector.ts +137 -137
  37. package/src/package.spec.ts +29 -29
@@ -1,137 +1,137 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2023 TypeFox and others.
3
- //
4
- // This program and the accompanying materials are made available under the
5
- // terms of the Eclipse Public License v. 2.0 which is available at
6
- // http://www.eclipse.org/legal/epl-2.0.
7
- //
8
- // This Source Code may also be made available under the following Secondary
9
- // Licenses when the conditions for such availability set forth in the Eclipse
10
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- // with the GNU Classpath Exception which is available at
12
- // https://www.gnu.org/software/classpath/license.html.
13
- //
14
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- import * as fs from '@theia/core/shared/fs-extra';
18
- import * as os from 'os';
19
- import * as path from 'path';
20
- import * as crypto from 'crypto';
21
- import { ParsedKey } from 'ssh2';
22
- import * as ssh2 from 'ssh2';
23
- import { injectable } from '@theia/core/shared/inversify';
24
-
25
- export interface SSHKey {
26
- filename: string;
27
- parsedKey: ParsedKey;
28
- fingerprint: string;
29
- agentSupport?: boolean;
30
- isPrivate?: boolean;
31
- }
32
-
33
- @injectable()
34
- export class SSHIdentityFileCollector {
35
-
36
- protected getDefaultIdentityFiles(): string[] {
37
- const homeDir = os.homedir();
38
- const PATH_SSH_CLIENT_ID_DSA = path.join(homeDir, '.ssh', '/id_dsa');
39
- const PATH_SSH_CLIENT_ID_ECDSA = path.join(homeDir, '.ssh', '/id_ecdsa');
40
- const PATH_SSH_CLIENT_ID_RSA = path.join(homeDir, '.ssh', '/id_rsa');
41
- const PATH_SSH_CLIENT_ID_ED25519 = path.join(homeDir, '.ssh', '/id_ed25519');
42
- const PATH_SSH_CLIENT_ID_XMSS = path.join(homeDir, '.ssh', '/id_xmss');
43
- const PATH_SSH_CLIENT_ID_ECDSA_SK = path.join(homeDir, '.ssh', '/id_ecdsa_sk');
44
- const PATH_SSH_CLIENT_ID_ED25519_SK = path.join(homeDir, '.ssh', '/id_ed25519_sk');
45
-
46
- return [
47
- PATH_SSH_CLIENT_ID_DSA,
48
- PATH_SSH_CLIENT_ID_ECDSA,
49
- PATH_SSH_CLIENT_ID_ECDSA_SK,
50
- PATH_SSH_CLIENT_ID_ED25519,
51
- PATH_SSH_CLIENT_ID_ED25519_SK,
52
- PATH_SSH_CLIENT_ID_RSA,
53
- PATH_SSH_CLIENT_ID_XMSS
54
- ];
55
- }
56
-
57
- async gatherIdentityFiles(sshAgentSock?: string): Promise<SSHKey[]> {
58
- const identityFiles = this.getDefaultIdentityFiles();
59
-
60
- const identityFileContentsResult = await Promise.allSettled(identityFiles.map(async keyPath => {
61
- keyPath = await fs.pathExists(keyPath + '.pub') ? keyPath + '.pub' : keyPath;
62
- return fs.promises.readFile(keyPath);
63
- }));
64
- const fileKeys: SSHKey[] = identityFileContentsResult.map((result, i) => {
65
- if (result.status === 'rejected') {
66
- return undefined;
67
- }
68
-
69
- const parsedResult = ssh2.utils.parseKey(result.value);
70
- if (parsedResult instanceof Error || !parsedResult) {
71
- console.log(`Error while parsing SSH public key ${identityFiles[i]}:`, parsedResult);
72
- return undefined;
73
- }
74
-
75
- const parsedKey = Array.isArray(parsedResult) ? parsedResult[0] : parsedResult;
76
- const fingerprint = crypto.createHash('sha256').update(parsedKey.getPublicSSH()).digest('base64');
77
-
78
- return {
79
- filename: identityFiles[i],
80
- parsedKey,
81
- fingerprint
82
- };
83
- }).filter(<T>(v: T | undefined): v is T => !!v);
84
-
85
- let sshAgentParsedKeys: ParsedKey[] = [];
86
- if (sshAgentSock) {
87
- sshAgentParsedKeys = await new Promise<ParsedKey[]>((resolve, reject) => {
88
- const sshAgent = new ssh2.OpenSSHAgent(sshAgentSock);
89
- sshAgent.getIdentities((err, publicKeys) => {
90
- if (err) {
91
- reject(err);
92
- } else if (publicKeys) {
93
- resolve(publicKeys.map(key => {
94
- if ('pubKey' in key) {
95
- const pubKey = key.pubKey;
96
- if ('pubKey' in pubKey) {
97
- return pubKey.pubKey as ParsedKey;
98
- }
99
- return pubKey;
100
- } else {
101
- return key;
102
- }
103
- }));
104
- } else {
105
- resolve([]);
106
- }
107
- });
108
- });
109
- }
110
-
111
- const sshAgentKeys: SSHKey[] = sshAgentParsedKeys.map(parsedKey => {
112
- const fingerprint = crypto.createHash('sha256').update(parsedKey.getPublicSSH()).digest('base64');
113
- return {
114
- filename: parsedKey.comment,
115
- parsedKey,
116
- fingerprint,
117
- agentSupport: true
118
- };
119
- });
120
-
121
- const agentKeys: SSHKey[] = [];
122
- const preferredIdentityKeys: SSHKey[] = [];
123
- for (const agentKey of sshAgentKeys) {
124
- const foundIdx = fileKeys.findIndex(k => agentKey.parsedKey.type === k.parsedKey.type && agentKey.fingerprint === k.fingerprint);
125
- if (foundIdx >= 0) {
126
- preferredIdentityKeys.push({ ...fileKeys[foundIdx], agentSupport: true });
127
- fileKeys.splice(foundIdx, 1);
128
- } else {
129
- agentKeys.push(agentKey);
130
- }
131
- }
132
- preferredIdentityKeys.push(...agentKeys);
133
- preferredIdentityKeys.push(...fileKeys);
134
-
135
- return preferredIdentityKeys;
136
- }
137
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2023 TypeFox and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import * as fs from '@theia/core/shared/fs-extra';
18
+ import * as os from 'os';
19
+ import * as path from 'path';
20
+ import * as crypto from 'crypto';
21
+ import { ParsedKey } from 'ssh2';
22
+ import * as ssh2 from 'ssh2';
23
+ import { injectable } from '@theia/core/shared/inversify';
24
+
25
+ export interface SSHKey {
26
+ filename: string;
27
+ parsedKey: ParsedKey;
28
+ fingerprint: string;
29
+ agentSupport?: boolean;
30
+ isPrivate?: boolean;
31
+ }
32
+
33
+ @injectable()
34
+ export class SSHIdentityFileCollector {
35
+
36
+ protected getDefaultIdentityFiles(): string[] {
37
+ const homeDir = os.homedir();
38
+ const PATH_SSH_CLIENT_ID_DSA = path.join(homeDir, '.ssh', '/id_dsa');
39
+ const PATH_SSH_CLIENT_ID_ECDSA = path.join(homeDir, '.ssh', '/id_ecdsa');
40
+ const PATH_SSH_CLIENT_ID_RSA = path.join(homeDir, '.ssh', '/id_rsa');
41
+ const PATH_SSH_CLIENT_ID_ED25519 = path.join(homeDir, '.ssh', '/id_ed25519');
42
+ const PATH_SSH_CLIENT_ID_XMSS = path.join(homeDir, '.ssh', '/id_xmss');
43
+ const PATH_SSH_CLIENT_ID_ECDSA_SK = path.join(homeDir, '.ssh', '/id_ecdsa_sk');
44
+ const PATH_SSH_CLIENT_ID_ED25519_SK = path.join(homeDir, '.ssh', '/id_ed25519_sk');
45
+
46
+ return [
47
+ PATH_SSH_CLIENT_ID_DSA,
48
+ PATH_SSH_CLIENT_ID_ECDSA,
49
+ PATH_SSH_CLIENT_ID_ECDSA_SK,
50
+ PATH_SSH_CLIENT_ID_ED25519,
51
+ PATH_SSH_CLIENT_ID_ED25519_SK,
52
+ PATH_SSH_CLIENT_ID_RSA,
53
+ PATH_SSH_CLIENT_ID_XMSS
54
+ ];
55
+ }
56
+
57
+ async gatherIdentityFiles(sshAgentSock?: string): Promise<SSHKey[]> {
58
+ const identityFiles = this.getDefaultIdentityFiles();
59
+
60
+ const identityFileContentsResult = await Promise.allSettled(identityFiles.map(async keyPath => {
61
+ keyPath = await fs.pathExists(keyPath + '.pub') ? keyPath + '.pub' : keyPath;
62
+ return fs.promises.readFile(keyPath);
63
+ }));
64
+ const fileKeys: SSHKey[] = identityFileContentsResult.map((result, i) => {
65
+ if (result.status === 'rejected') {
66
+ return undefined;
67
+ }
68
+
69
+ const parsedResult = ssh2.utils.parseKey(result.value);
70
+ if (parsedResult instanceof Error || !parsedResult) {
71
+ console.log(`Error while parsing SSH public key ${identityFiles[i]}:`, parsedResult);
72
+ return undefined;
73
+ }
74
+
75
+ const parsedKey = Array.isArray(parsedResult) ? parsedResult[0] : parsedResult;
76
+ const fingerprint = crypto.createHash('sha256').update(parsedKey.getPublicSSH()).digest('base64');
77
+
78
+ return {
79
+ filename: identityFiles[i],
80
+ parsedKey,
81
+ fingerprint
82
+ };
83
+ }).filter(<T>(v: T | undefined): v is T => !!v);
84
+
85
+ let sshAgentParsedKeys: ParsedKey[] = [];
86
+ if (sshAgentSock) {
87
+ sshAgentParsedKeys = await new Promise<ParsedKey[]>((resolve, reject) => {
88
+ const sshAgent = new ssh2.OpenSSHAgent(sshAgentSock);
89
+ sshAgent.getIdentities((err, publicKeys) => {
90
+ if (err) {
91
+ reject(err);
92
+ } else if (publicKeys) {
93
+ resolve(publicKeys.map(key => {
94
+ if ('pubKey' in key) {
95
+ const pubKey = key.pubKey;
96
+ if ('pubKey' in pubKey) {
97
+ return pubKey.pubKey as ParsedKey;
98
+ }
99
+ return pubKey;
100
+ } else {
101
+ return key;
102
+ }
103
+ }));
104
+ } else {
105
+ resolve([]);
106
+ }
107
+ });
108
+ });
109
+ }
110
+
111
+ const sshAgentKeys: SSHKey[] = sshAgentParsedKeys.map(parsedKey => {
112
+ const fingerprint = crypto.createHash('sha256').update(parsedKey.getPublicSSH()).digest('base64');
113
+ return {
114
+ filename: parsedKey.comment,
115
+ parsedKey,
116
+ fingerprint,
117
+ agentSupport: true
118
+ };
119
+ });
120
+
121
+ const agentKeys: SSHKey[] = [];
122
+ const preferredIdentityKeys: SSHKey[] = [];
123
+ for (const agentKey of sshAgentKeys) {
124
+ const foundIdx = fileKeys.findIndex(k => agentKey.parsedKey.type === k.parsedKey.type && agentKey.fingerprint === k.fingerprint);
125
+ if (foundIdx >= 0) {
126
+ preferredIdentityKeys.push({ ...fileKeys[foundIdx], agentSupport: true });
127
+ fileKeys.splice(foundIdx, 1);
128
+ } else {
129
+ agentKeys.push(agentKey);
130
+ }
131
+ }
132
+ preferredIdentityKeys.push(...agentKeys);
133
+ preferredIdentityKeys.push(...fileKeys);
134
+
135
+ return preferredIdentityKeys;
136
+ }
137
+ }
@@ -1,29 +1,29 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2023 TypeFox and others.
3
- //
4
- // This program and the accompanying materials are made available under the
5
- // terms of the Eclipse Public License v. 2.0 which is available at
6
- // http://www.eclipse.org/legal/epl-2.0.
7
- //
8
- // This Source Code may also be made available under the following Secondary
9
- // Licenses when the conditions for such availability set forth in the Eclipse
10
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- // with the GNU Classpath Exception which is available at
12
- // https://www.gnu.org/software/classpath/license.html.
13
- //
14
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- /* note: this bogus test file is required so that
18
- we are able to run mocha unit tests on this
19
- package, without having any actual unit tests in it.
20
- This way a coverage report will be generated,
21
- showing 0% coverage, instead of no report.
22
- This file can be removed once we have real unit
23
- tests in place. */
24
-
25
- describe('remote package', () => {
26
-
27
- it('support code coverage statistics', () => true);
28
-
29
- });
1
+ // *****************************************************************************
2
+ // Copyright (C) 2023 TypeFox and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ /* note: this bogus test file is required so that
18
+ we are able to run mocha unit tests on this
19
+ package, without having any actual unit tests in it.
20
+ This way a coverage report will be generated,
21
+ showing 0% coverage, instead of no report.
22
+ This file can be removed once we have real unit
23
+ tests in place. */
24
+
25
+ describe('remote package', () => {
26
+
27
+ it('support code coverage statistics', () => true);
28
+
29
+ });