wative 1.1.15 → 1.1.17
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.
- package/lib/account.d.ts +14 -0
- package/lib/account.d.ts.map +1 -0
- package/lib/assets.d.ts +11 -0
- package/lib/assets.d.ts.map +1 -0
- package/lib/chain.d.ts +6 -0
- package/lib/chain.d.ts.map +1 -0
- package/lib/config.d.ts +23 -0
- package/lib/config.d.ts.map +1 -0
- package/lib/daemon-watcher.js +181 -0
- package/lib/home_page.d.ts +4 -0
- package/lib/home_page.d.ts.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.esm.js +1 -1
- package/lib/index.umd.js +1 -1
- package/lib/network.d.ts +28 -0
- package/lib/network.d.ts.map +1 -0
- package/lib/ssh/client.d.ts +120 -0
- package/lib/ssh/client.d.ts.map +1 -0
- package/lib/ssh/client_example.d.ts +19 -0
- package/lib/ssh/client_example.d.ts.map +1 -0
- package/lib/ssh/client_test.d.ts +27 -0
- package/lib/ssh/client_test.d.ts.map +1 -0
- package/lib/ssh/config_manager.d.ts +55 -0
- package/lib/ssh/config_manager.d.ts.map +1 -0
- package/lib/ssh/config_template.d.ts +52 -0
- package/lib/ssh/config_template.d.ts.map +1 -0
- package/lib/ssh/index.d.ts +7 -0
- package/lib/ssh/index.d.ts.map +1 -0
- package/lib/ssh/remote_server_example.d.ts +16 -0
- package/lib/ssh/remote_server_example.d.ts.map +1 -0
- package/lib/ssh/service_manager.d.ts +119 -0
- package/lib/ssh/service_manager.d.ts.map +1 -0
- package/lib/ssh/types.d.ts +45 -0
- package/lib/ssh/types.d.ts.map +1 -0
- package/lib/ssh/utils.d.ts +11 -0
- package/lib/ssh/utils.d.ts.map +1 -0
- package/lib/ssh/wative_server.d.ts +26 -0
- package/lib/ssh/wative_server.d.ts.map +1 -0
- package/lib/tools.d.ts +6 -0
- package/lib/tools.d.ts.map +1 -0
- package/lib/tx_gas_utils.d.ts +18 -0
- package/lib/tx_gas_utils.d.ts.map +1 -0
- package/lib/utils.d.ts +49 -0
- package/lib/utils.d.ts.map +1 -0
- package/lib/wative.d.ts +2 -0
- package/lib/wative.d.ts.map +1 -0
- package/lib/wative.esm.js +1 -1
- package/lib/wative.umd.js +1 -1
- package/lib/web3.d.ts +59 -0
- package/lib/web3.d.ts.map +1 -0
- package/package.json +9 -5
- package/src/assets.ts +1 -10
- package/src/daemon-watcher.js +181 -0
- package/src/ssh/client.rs +221 -0
- package/src/ssh/client.ts +389 -0
- package/src/ssh/config_manager.ts +317 -0
- package/src/ssh/index.ts +49 -36
- package/src/ssh/service_manager.ts +684 -0
- package/src/ssh/types.ts +35 -1
- package/src/ssh/wative_server.ts +1 -2
- package/src/wative.ts +560 -122
- package/bin/wative-ssh.sh +0 -44
- package/lib/wative-ssh.esm.js +0 -1
- package/lib/wative-ssh.umd.js +0 -1
package/src/ssh/index.ts
CHANGED
|
@@ -1,52 +1,65 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { SSHServiceManager } from './service_manager';
|
|
2
|
+
|
|
3
|
+
// Export the new SSH client
|
|
4
|
+
export { WativeSSHClient, SSHConfig, createWativeSSHClient } from './client';
|
|
5
|
+
export { WativeWielderServer } from './wative_server';
|
|
6
|
+
export * from './types';
|
|
7
|
+
export * from './utils';
|
|
4
8
|
|
|
5
9
|
require('dotenv').config();
|
|
6
|
-
const os = require('os');
|
|
7
10
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const keystore = allowedKeystores[i].replace(/-/g, '_');
|
|
12
|
-
passwords.push(process.env[keystore]);
|
|
13
|
-
}
|
|
14
|
-
return passwords;
|
|
15
|
-
}
|
|
11
|
+
// 新的主函数,支持多配置文件
|
|
12
|
+
const mainWithConfig = async (configName?: string) => {
|
|
13
|
+
const serviceManager = new SSHServiceManager();
|
|
16
14
|
|
|
15
|
+
try {
|
|
16
|
+
// 配置名称是必需的
|
|
17
|
+
if (!configName) {
|
|
18
|
+
throw new Error('Configuration name is required. Please specify a configuration name.');
|
|
19
|
+
}
|
|
17
20
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const keystorePath = path.join(userHomeDirectory, '.wative');
|
|
21
|
+
console.log(`Starting SSH service with configuration: ${configName}`);
|
|
22
|
+
await serviceManager.startService(configName);
|
|
21
23
|
|
|
22
|
-
|
|
24
|
+
console.log('SSH service started successfully.');
|
|
23
25
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
// 保持进程运行
|
|
27
|
+
process.on('SIGINT', async () => {
|
|
28
|
+
console.log('\nShutting down SSH services...');
|
|
29
|
+
await serviceManager.stopAllServices();
|
|
30
|
+
process.exit(0);
|
|
31
|
+
});
|
|
28
32
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
process.on('SIGTERM', async () => {
|
|
34
|
+
console.log('\nShutting down SSH services...');
|
|
35
|
+
await serviceManager.stopAllServices();
|
|
36
|
+
process.exit(0);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
} catch (error: any) {
|
|
40
|
+
console.error(`Failed to start SSH service: ${error.message}`);
|
|
41
|
+
process.exit(1);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
33
44
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
[client_keystores],
|
|
40
|
-
keystorePath,
|
|
41
|
-
client_keystores,
|
|
42
|
-
client_keystore_passwords,
|
|
43
|
-
);
|
|
45
|
+
// 检查命令行参数
|
|
46
|
+
const args = process.argv.slice(2);
|
|
47
|
+
const isDaemon = args.includes('--daemon');
|
|
48
|
+
const configIndex = args.indexOf('--config');
|
|
49
|
+
const configName = configIndex !== -1 && args[configIndex + 1] ? args[configIndex + 1] : undefined;
|
|
44
50
|
|
|
45
|
-
|
|
51
|
+
// 根据参数选择启动方式
|
|
52
|
+
if (isDaemon || configName) {
|
|
53
|
+
// 使用新的多配置文件方式
|
|
54
|
+
mainWithConfig(configName).catch(error => {
|
|
55
|
+
console.error('Failed to start SSH service:', error);
|
|
56
|
+
process.exit(1);
|
|
57
|
+
});
|
|
46
58
|
}
|
|
47
59
|
|
|
48
60
|
process.on('unhandledRejection', (reason, p) => {
|
|
49
61
|
console.log('Unhandled Rejection at:', p, 'reason:', reason);
|
|
50
62
|
});
|
|
51
63
|
|
|
52
|
-
|
|
64
|
+
// 导出函数供其他模块使用
|
|
65
|
+
export { mainWithConfig };
|