jjb-cmd 2.5.7 → 2.5.9

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/src/auth.js CHANGED
@@ -1,71 +1 @@
1
- const axios = require('axios');
2
- const path = require('path');
3
- const { getApiHost } = require('./config');
4
- const {
5
- logInfo,
6
- logSuccess,
7
- logError,
8
- fileExists,
9
- deleteFile
10
- } = require('./utils');
11
- const { saveAuth, deleteAuth } = require('./crypto-utils');
12
- const { getCredentials, interactiveAuth } = require('./password-input');
13
-
14
- /**
15
- * 用户认证模块
16
- * @param {string[]} args - 命令行参数(不再使用)
17
- */
18
- module.exports = async (args) => {
19
- const authPath = path.join(__dirname, '../.auth');
20
-
21
- try {
22
- // 强制使用完全交互式模式
23
- logInfo('启动交互式登录流程');
24
- const credentials = await interactiveAuth();
25
- const username = credentials.username;
26
- const password = credentials.password;
27
-
28
- logInfo('正在验证用户凭证...');
29
-
30
- // 验证登录
31
- const response = await axios.post(`${getApiHost()}/api/auth`, {
32
- username,
33
- password
34
- });
35
-
36
- if (response.data.status) {
37
- logSuccess('用户认证成功');
38
- try {
39
- saveAuth(username, password, authPath);
40
- logSuccess('认证信息已安全加密存储');
41
- } catch (error) {
42
- logError(`保存认证信息失败: ${error.message}`);
43
- process.exit(1);
44
- }
45
- } else {
46
- logError(`认证失败: ${response.data.message || '未知错误'}`);
47
- if (fileExists(authPath)) {
48
- deleteAuth(authPath);
49
- logInfo('已清理无效的认证信息');
50
- }
51
- process.exit(1);
52
- }
53
- } catch (error) {
54
- if (error.message.includes('用户取消输入')) {
55
- logError('用户取消登录操作');
56
- } else if (error.response) {
57
- const status = error.response.status;
58
- const message = error.response.data?.message || error.message;
59
- if (status === 401 || status === 403) {
60
- logError(`认证失败 (${status}): 用户名或密码错误`);
61
- } else {
62
- logError(`请求失败 (${status}): ${message}`);
63
- }
64
- } else if (error.request) {
65
- logError(`网络连接失败: 无法连接到服务器`);
66
- } else {
67
- logError(`登录失败: ${error.message}`);
68
- }
69
- process.exit(1);
70
- }
71
- };
1
+ function a1_0x2e58(_0x4d997d,_0x45efd0){_0x4d997d=_0x4d997d-0x18f;const _0x1c37f7=a1_0x1c37();let _0x2e5810=_0x1c37f7[_0x4d997d];return _0x2e5810;}const a1_0x594a23=a1_0x2e58;function a1_0x1c37(){const _0x1a0705=['status','post','axios','正在验证用户凭证...','用户取消登录操作','./crypto-utils','1CqVasx','用户认证成功','request','../.auth','join','505415hWyQhH','./utils','response','exit','用户取消输入','472fwDSml','537093CkZgAI','includes','认证失败\x20(','网络连接失败:\x20无法连接到服务器','1280112CxSmMY','41638uDoxVh','未知错误','message','data','已清理无效的认证信息','password','697584Yaoscj','468291rnIOxQ','保存认证信息失败:\x20','请求失败\x20(','认证信息已安全加密存储','):\x20用户名或密码错误','./config','启动交互式登录流程','):\x20','7903iIJFlM','/api/auth','./password-input'];a1_0x1c37=function(){return _0x1a0705;};return a1_0x1c37();}(function(_0x3ad433,_0x556db7){const _0x5bd04b=a1_0x2e58,_0x33cb02=_0x3ad433();while(!![]){try{const _0x8332dc=parseInt(_0x5bd04b(0x1b3))/0x1*(parseInt(_0x5bd04b(0x19b))/0x2)+parseInt(_0x5bd04b(0x1a2))/0x3+parseInt(_0x5bd04b(0x1a1))/0x4+parseInt(_0x5bd04b(0x190))/0x5+-parseInt(_0x5bd04b(0x19a))/0x6+-parseInt(_0x5bd04b(0x1aa))/0x7*(-parseInt(_0x5bd04b(0x195))/0x8)+-parseInt(_0x5bd04b(0x196))/0x9;if(_0x8332dc===_0x556db7)break;else _0x33cb02['push'](_0x33cb02['shift']());}catch(_0xb465bb){_0x33cb02['push'](_0x33cb02['shift']());}}}(a1_0x1c37,0x3c0d9));const axios=require(a1_0x594a23(0x1af)),path=require('path'),{getApiHost}=require(a1_0x594a23(0x1a7)),{logInfo,logSuccess,logError,fileExists,deleteFile}=require(a1_0x594a23(0x191)),{saveAuth,deleteAuth}=require(a1_0x594a23(0x1b2)),{getCredentials,interactiveAuth}=require(a1_0x594a23(0x1ac));module['exports']=async _0x1cb5d9=>{const _0x20e801=a1_0x594a23,_0x2675ee=path[_0x20e801(0x18f)](__dirname,_0x20e801(0x1b6));try{logInfo(_0x20e801(0x1a8));const _0x2b963c=await interactiveAuth(),_0x2ae553=_0x2b963c['username'],_0x282832=_0x2b963c[_0x20e801(0x1a0)];logInfo(_0x20e801(0x1b0));const _0x18aa36=await axios[_0x20e801(0x1ae)](getApiHost()+_0x20e801(0x1ab),{'username':_0x2ae553,'password':_0x282832});if(_0x18aa36[_0x20e801(0x19e)]['status']){logSuccess(_0x20e801(0x1b4));try{saveAuth(_0x2ae553,_0x282832,_0x2675ee),logSuccess(_0x20e801(0x1a5));}catch(_0x261823){logError(_0x20e801(0x1a3)+_0x261823['message']),process[_0x20e801(0x193)](0x1);}}else logError('认证失败:\x20'+(_0x18aa36[_0x20e801(0x19e)]['message']||_0x20e801(0x19c))),fileExists(_0x2675ee)&&(deleteAuth(_0x2675ee),logInfo(_0x20e801(0x19f))),process[_0x20e801(0x193)](0x1);}catch(_0x4c3a0d){if(_0x4c3a0d[_0x20e801(0x19d)][_0x20e801(0x197)](_0x20e801(0x194)))logError(_0x20e801(0x1b1));else{if(_0x4c3a0d[_0x20e801(0x192)]){const _0x383eb7=_0x4c3a0d[_0x20e801(0x192)][_0x20e801(0x1ad)],_0x5f037b=_0x4c3a0d[_0x20e801(0x192)][_0x20e801(0x19e)]?.['message']||_0x4c3a0d[_0x20e801(0x19d)];_0x383eb7===0x191||_0x383eb7===0x193?logError(_0x20e801(0x198)+_0x383eb7+_0x20e801(0x1a6)):logError(_0x20e801(0x1a4)+_0x383eb7+_0x20e801(0x1a9)+_0x5f037b);}else _0x4c3a0d[_0x20e801(0x1b5)]?logError(_0x20e801(0x199)):logError('登录失败:\x20'+_0x4c3a0d[_0x20e801(0x19d)]);}process[_0x20e801(0x193)](0x1);}};
@@ -1,46 +1 @@
1
- const path = require('path');
2
- const inquirer = require('inquirer');
3
- const { bootstrap } = require('@cqsjjb/react-code-optimization');
4
- const {
5
- logInfo,
6
- logSuccess,
7
- logError,
8
- logWarning
9
- } = require('./utils');
10
-
11
- /**
12
- * 代码优化模块
13
- * 使用 @cqsjjb/react-code-optimization 进行代码优化
14
- */
15
- module.exports = async function () {
16
- const rootPath = path.resolve('./');
17
-
18
- logInfo('代码优化工具已启动');
19
- logWarning('此操作将优化当前目录下的代码,请确保已备份重要文件');
20
-
21
- const { confirmed } = await inquirer.prompt([
22
- {
23
- type: 'confirm',
24
- name: 'confirmed',
25
- message: '是否确认优化代码?',
26
- default: false
27
- }
28
- ]);
29
-
30
- if (confirmed) {
31
- logInfo('正在分析代码结构...');
32
-
33
- try {
34
- bootstrap(rootPath, 100, () => {
35
- logSuccess('代码优化已完成');
36
- process.exit(0);
37
- });
38
- } catch (error) {
39
- logError(`代码优化失败: ${error.message}`);
40
- process.exit(1);
41
- }
42
- } else {
43
- logInfo('操作已取消');
44
- process.exit(0);
45
- }
46
- };
1
+ function a2_0x8e3f(){const _0x466dcd=['818190bEWCdg','116oscDqc','59125116ePwtRx','446666pWDvyJ','602uWRPbN','21455NBtXAY','@cqsjjb/react-code-optimization','confirmed','resolve','82008OxXdjG','此操作将优化当前目录下的代码,请确保已备份重要文件','是否确认优化代码?','80hiXJnC','3bhuYfe','代码优化已完成','exports','exit','代码优化工具已启动','confirm','1045162cUKVTX','代码优化失败:\x20','1027400OTrPzC','path','./utils','操作已取消','inquirer','正在分析代码结构...','110YGUdBB','message'];a2_0x8e3f=function(){return _0x466dcd;};return a2_0x8e3f();}const a2_0x297baa=a2_0xfe3d;(function(_0x5410c3,_0x1fca1b){const _0xc645d0=a2_0xfe3d,_0x576d17=_0x5410c3();while(!![]){try{const _0x4a785c=-parseInt(_0xc645d0(0x161))/0x1+-parseInt(_0xc645d0(0x16e))/0x2*(-parseInt(_0xc645d0(0x178))/0x3)+-parseInt(_0xc645d0(0x16c))/0x4*(parseInt(_0xc645d0(0x170))/0x5)+parseInt(_0xc645d0(0x174))/0x6*(-parseInt(_0xc645d0(0x16f))/0x7)+-parseInt(_0xc645d0(0x177))/0x8*(parseInt(_0xc645d0(0x16b))/0x9)+-parseInt(_0xc645d0(0x163))/0xa*(parseInt(_0xc645d0(0x169))/0xb)+parseInt(_0xc645d0(0x16d))/0xc;if(_0x4a785c===_0x1fca1b)break;else _0x576d17['push'](_0x576d17['shift']());}catch(_0x4919b6){_0x576d17['push'](_0x576d17['shift']());}}}(a2_0x8e3f,0xd420d));function a2_0xfe3d(_0x16439d,_0x3c6199){_0x16439d=_0x16439d-0x160;const _0x8e3f34=a2_0x8e3f();let _0xfe3d94=_0x8e3f34[_0x16439d];return _0xfe3d94;}const path=require(a2_0x297baa(0x164)),inquirer=require(a2_0x297baa(0x167)),{bootstrap}=require(a2_0x297baa(0x171)),{logInfo,logSuccess,logError,logWarning}=require(a2_0x297baa(0x165));module[a2_0x297baa(0x17a)]=async function(){const _0x3ee20c=a2_0x297baa,_0x2b0061=path[_0x3ee20c(0x173)]('./');logInfo(_0x3ee20c(0x17c)),logWarning(_0x3ee20c(0x175));const {confirmed:_0x147b6f}=await inquirer['prompt']([{'type':_0x3ee20c(0x160),'name':_0x3ee20c(0x172),'message':_0x3ee20c(0x176),'default':![]}]);if(_0x147b6f){logInfo(_0x3ee20c(0x168));try{bootstrap(_0x2b0061,0x64,()=>{const _0x26e8e6=_0x3ee20c;logSuccess(_0x26e8e6(0x179)),process[_0x26e8e6(0x17b)](0x0);});}catch(_0x5f4df4){logError(_0x3ee20c(0x162)+_0x5f4df4[_0x3ee20c(0x16a)]),process[_0x3ee20c(0x17b)](0x1);}}else logInfo(_0x3ee20c(0x166)),process[_0x3ee20c(0x17b)](0x0);};
package/src/config.js CHANGED
@@ -1,122 +1 @@
1
- const os = require('os');
2
- const path = require('path');
3
- const fs = require('fs');
4
-
5
- /**
6
- * API 主机配置
7
- */
8
- const API_HOST = 'http://120.26.210.58:8088';
9
- const API_HOST_HTTPS = 'https://jcloud.cqjjb.cn';
10
- const API_HOST_TEST = 'http://120.26.210.58:8089';
11
-
12
- /**
13
- * 配置文件主机地址
14
- */
15
- exports.CONFIG_FILE_HOST = 'https://cdn.cqjjb.cn/jjb-cloud-config';
16
-
17
- /**
18
- * API 主机地址
19
- */
20
- exports.API_HOST = API_HOST;
21
-
22
- /**
23
- * 测试环境 API 主机地址
24
- */
25
- exports.API_HOST_TEST = API_HOST_TEST;
26
-
27
- /**
28
- * Git 主机地址
29
- */
30
- exports.GIT_HOST = 'http://192.168.1.242:10985';
31
-
32
- /**
33
- * 临时目录名称
34
- */
35
- exports.GIT_TEMP_DIR = `jjb-assembly-${Date.now()}`;
36
-
37
- /**
38
- * Java 临时目录名称
39
- */
40
- exports.GIT_TEMP_JAVA = `jjb-assembly-java`;
41
-
42
- /**
43
- * Java 环境映射
44
- */
45
- exports.GIT_JAVA_ENV_JSON = {
46
- development: 'dev',
47
- production: 'prod',
48
- test: 'test'
49
- };
50
- /**
51
- * 云项目配置
52
- * 包含各个项目的 token 和 projectId
53
- */
54
- exports.CLOUD_PROJECT = {
55
- common: {
56
- token: 'G4HJRsHr9D7Ssmixegw2',
57
- projectId: 279
58
- },
59
- 'react-admin-component': {
60
- token: 'FT3pKzxpRynFkmddJ9Bs',
61
- projectId: 340
62
- },
63
- 'jjb-dva-runtime': {
64
- token: 'hLqARY89CN6fUD3yg4NL',
65
- projectId: 571
66
- },
67
- 'jjb-common-lib': {
68
- token: 'e9njpBd1nS_LREN8GFpR',
69
- projectId: 572
70
- },
71
- 'jjb-common-decorator': {
72
- token: 'gPSit8aJsLVmNzuQ5Cy4',
73
- projectId: 574
74
- },
75
- 'vue-unisass-component': {
76
- token: 'd4wQ7dzEjYPsgVbKnYei',
77
- projectId: 339
78
- },
79
- 'react-component': {
80
- token: 'snBxJ2i5kYarGGcsojhY',
81
- projectId: 831
82
- },
83
- 'micro-app-ts': {
84
- token: '7V-YUxhmh51Mdhgx4rq4',
85
- projectId: 830
86
- },
87
- 'micro-app': {
88
- token: 'FqNrmFAgrxasMrbbjvq9',
89
- projectId: 829
90
- },
91
- lib: {
92
- token: 'ywPtT3xCG6b_vAxp6sTj',
93
- projectId: 828
94
- }
95
- };
96
-
97
- /**
98
- * 模板文件夹路径
99
- */
100
- exports.TEMPLATE_FOLDER = path.join(os.tmpdir(), exports.GIT_TEMP_DIR);
101
-
102
- /**
103
- * 获取 API 主机地址
104
- * 根据 package.json 中的配置决定使用哪个 API 主机
105
- * @returns {string} API 主机地址
106
- */
107
- exports.getApiHost = () => {
108
- try {
109
- const packageJson = JSON.parse(
110
- fs.readFileSync(path.join(__dirname, '../package.json')).toString()
111
- );
112
-
113
- if (packageJson.env === 'test') {
114
- return API_HOST_TEST;
115
- } else {
116
- return packageJson.httpMethod === 'http' ? API_HOST : API_HOST_HTTPS;
117
- }
118
- } catch (error) {
119
- // 如果读取 package.json 失败,默认返回 HTTPS 地址
120
- return API_HOST_HTTPS;
121
- }
122
- };
1
+ const a3_0x49b426=a3_0x412a;(function(_0x13f27c,_0x599e29){const _0x10050b=a3_0x412a,_0x40a3c4=_0x13f27c();while(!![]){try{const _0x2174ed=parseInt(_0x10050b(0x141))/0x1+-parseInt(_0x10050b(0x154))/0x2*(-parseInt(_0x10050b(0x161))/0x3)+-parseInt(_0x10050b(0x14a))/0x4+parseInt(_0x10050b(0x148))/0x5*(parseInt(_0x10050b(0x143))/0x6)+parseInt(_0x10050b(0x163))/0x7*(parseInt(_0x10050b(0x159))/0x8)+parseInt(_0x10050b(0x167))/0x9+-parseInt(_0x10050b(0x146))/0xa;if(_0x2174ed===_0x599e29)break;else _0x40a3c4['push'](_0x40a3c4['shift']());}catch(_0x198f56){_0x40a3c4['push'](_0x40a3c4['shift']());}}}(a3_0x4396,0x19ab9));const os=require('os'),path=require(a3_0x49b426(0x14f)),fs=require('fs'),API_HOST='http://120.26.210.58:8088',API_HOST_HTTPS='https://jcloud.cqjjb.cn',API_HOST_TEST=a3_0x49b426(0x150);function a3_0x412a(_0x34669f,_0x58801c){_0x34669f=_0x34669f-0x140;const _0x4396d6=a3_0x4396();let _0x412acb=_0x4396d6[_0x34669f];return _0x412acb;}exports[a3_0x49b426(0x140)]=a3_0x49b426(0x15a),exports[a3_0x49b426(0x14b)]=API_HOST,exports[a3_0x49b426(0x153)]=API_HOST_TEST,exports['GIT_HOST']=a3_0x49b426(0x160),exports[a3_0x49b426(0x152)]=a3_0x49b426(0x15f)+Date[a3_0x49b426(0x162)](),exports[a3_0x49b426(0x151)]=a3_0x49b426(0x14e),exports[a3_0x49b426(0x14d)]={'development':a3_0x49b426(0x149),'production':'prod','test':a3_0x49b426(0x145)},exports['CLOUD_PROJECT']={'common':{'token':a3_0x49b426(0x144),'projectId':0x117},'react-admin-component':{'token':'FT3pKzxpRynFkmddJ9Bs','projectId':0x154},'jjb-dva-runtime':{'token':a3_0x49b426(0x14c),'projectId':0x23b},'jjb-common-lib':{'token':a3_0x49b426(0x142),'projectId':0x23c},'jjb-common-decorator':{'token':a3_0x49b426(0x15c),'projectId':0x23e},'vue-unisass-component':{'token':a3_0x49b426(0x15d),'projectId':0x153},'react-component':{'token':a3_0x49b426(0x164),'projectId':0x33f},'micro-app-ts':{'token':a3_0x49b426(0x155),'projectId':0x33e},'micro-app':{'token':a3_0x49b426(0x157),'projectId':0x33d},'lib':{'token':a3_0x49b426(0x168),'projectId':0x33c}},exports[a3_0x49b426(0x147)]=path['join'](os['tmpdir'](),exports[a3_0x49b426(0x152)]),exports[a3_0x49b426(0x165)]=()=>{const _0x2a6a03=a3_0x49b426;try{const _0x25d74f=JSON['parse'](fs[_0x2a6a03(0x15b)](path['join'](__dirname,'../package.json'))[_0x2a6a03(0x158)]());return _0x25d74f[_0x2a6a03(0x15e)]===_0x2a6a03(0x145)?API_HOST_TEST:_0x25d74f[_0x2a6a03(0x166)]===_0x2a6a03(0x156)?API_HOST:API_HOST_HTTPS;}catch(_0x4c3b20){return API_HOST_HTTPS;}};function a3_0x4396(){const _0x3f405e=['jjb-assembly-','http://192.168.1.242:10985','3caaSgQ','now','77AEQAtA','snBxJ2i5kYarGGcsojhY','getApiHost','httpMethod','950166KumIGa','ywPtT3xCG6b_vAxp6sTj','CONFIG_FILE_HOST','134267rTVaET','e9njpBd1nS_LREN8GFpR','124152LSVdBe','G4HJRsHr9D7Ssmixegw2','test','4554680HJFzQZ','TEMPLATE_FOLDER','40yKYaFS','dev','592704Qhjtvf','API_HOST','hLqARY89CN6fUD3yg4NL','GIT_JAVA_ENV_JSON','jjb-assembly-java','path','http://120.26.210.58:8089','GIT_TEMP_JAVA','GIT_TEMP_DIR','API_HOST_TEST','302740ZVGiuc','7V-YUxhmh51Mdhgx4rq4','http','FqNrmFAgrxasMrbbjvq9','toString','110576XENftM','https://cdn.cqjjb.cn/jjb-cloud-config','readFileSync','gPSit8aJsLVmNzuQ5Cy4','d4wQ7dzEjYPsgVbKnYei','env'];a3_0x4396=function(){return _0x3f405e;};return a3_0x4396();}
@@ -1,183 +1 @@
1
- const crypto = require('crypto');
2
- const fs = require('fs');
3
- const path = require('path');
4
-
5
- /**
6
- * 加密配置
7
- */
8
- const CRYPTO_CONFIG = {
9
- algorithm: 'aes-256-cbc',
10
- keyLength: 32, // 256 bits
11
- ivLength: 16, // 128 bits
12
- saltLength: 32 // 256 bits
13
- };
14
-
15
- /**
16
- * 生成加密密钥
17
- * @param {string} password - 主密码
18
- * @param {Buffer} salt - 盐值
19
- * @returns {Buffer} 加密密钥
20
- */
21
- function deriveKey(password, salt) {
22
- return crypto.pbkdf2Sync(password, salt, 100000, CRYPTO_CONFIG.keyLength, 'sha512');
23
- }
24
-
25
- /**
26
- * 生成随机盐值
27
- * @returns {Buffer} 随机盐值
28
- */
29
- function generateSalt() {
30
- return crypto.randomBytes(CRYPTO_CONFIG.saltLength);
31
- }
32
-
33
- /**
34
- * 生成随机IV
35
- * @returns {Buffer} 随机IV
36
- */
37
- function generateIV() {
38
- return crypto.randomBytes(CRYPTO_CONFIG.ivLength);
39
- }
40
-
41
- /**
42
- * 加密数据
43
- * @param {string} text - 要加密的文本
44
- * @param {string} password - 加密密码
45
- * @returns {string} 加密后的数据(base64编码)
46
- */
47
- function encrypt(text, password) {
48
- try {
49
- const salt = generateSalt();
50
- const iv = generateIV();
51
- const key = deriveKey(password, salt);
52
-
53
- const cipher = crypto.createCipheriv(CRYPTO_CONFIG.algorithm, key, iv);
54
- cipher.setAutoPadding(true);
55
-
56
- let encrypted = cipher.update(text, 'utf8', 'hex');
57
- encrypted += cipher.final('hex');
58
-
59
- // 组合数据:salt + iv + encrypted
60
- const combined = Buffer.concat([salt, iv, Buffer.from(encrypted, 'hex')]);
61
-
62
- return combined.toString('base64');
63
- } catch (error) {
64
- throw new Error(`加密失败: ${error.message}`);
65
- }
66
- }
67
-
68
- /**
69
- * 解密数据
70
- * @param {string} encryptedData - 加密的数据(base64编码)
71
- * @param {string} password - 解密密码
72
- * @returns {string} 解密后的文本
73
- */
74
- function decrypt(encryptedData, password) {
75
- try {
76
- const combined = Buffer.from(encryptedData, 'base64');
77
-
78
- // 分离数据
79
- const salt = combined.slice(0, CRYPTO_CONFIG.saltLength);
80
- const iv = combined.slice(CRYPTO_CONFIG.saltLength, CRYPTO_CONFIG.saltLength + CRYPTO_CONFIG.ivLength);
81
- const encrypted = combined.slice(CRYPTO_CONFIG.saltLength + CRYPTO_CONFIG.ivLength);
82
-
83
- const key = deriveKey(password, salt);
84
-
85
- const decipher = crypto.createDecipheriv(CRYPTO_CONFIG.algorithm, key, iv);
86
- decipher.setAutoPadding(true);
87
-
88
- let decrypted = decipher.update(encrypted, null, 'utf8');
89
- decrypted += decipher.final('utf8');
90
-
91
- return decrypted;
92
- } catch (error) {
93
- throw new Error(`解密失败: ${error.message}`);
94
- }
95
- }
96
-
97
- /**
98
- * 生成设备特定的加密密钥
99
- * 基于系统信息生成,确保密钥的唯一性
100
- * @returns {string} 设备密钥
101
- */
102
- function generateDeviceKey() {
103
- const os = require('os');
104
- const machineInfo = [
105
- os.platform(),
106
- os.arch(),
107
- os.hostname(),
108
- os.userInfo().username || 'unknown'
109
- ].join('|');
110
-
111
- return crypto.createHash('sha256').update(machineInfo).digest('hex');
112
- }
113
-
114
- /**
115
- * 安全存储认证信息
116
- * @param {string} username - 用户名
117
- * @param {string} password - 密码
118
- * @param {string} authPath - 认证文件路径
119
- */
120
- function saveAuth(username, password, authPath) {
121
- try {
122
- const deviceKey = generateDeviceKey();
123
- const authData = `${username}/${password}`;
124
- const encryptedData = encrypt(authData, deviceKey);
125
-
126
- // 设置文件权限为仅当前用户可读写
127
- fs.writeFileSync(authPath, encryptedData, { mode: 0o600 });
128
-
129
- return true;
130
- } catch (error) {
131
- throw new Error(`保存认证信息失败: ${error.message}`);
132
- }
133
- }
134
-
135
- /**
136
- * 安全读取认证信息
137
- * @param {string} authPath - 认证文件路径
138
- * @returns {Object} 包含用户名和密码的对象
139
- */
140
- function loadAuth(authPath) {
141
- try {
142
- if (!fs.existsSync(authPath)) {
143
- throw new Error('认证文件不存在');
144
- }
145
-
146
- const deviceKey = generateDeviceKey();
147
- const encryptedData = fs.readFileSync(authPath, 'utf8');
148
- const decryptedData = decrypt(encryptedData, deviceKey);
149
-
150
- const [username, password] = decryptedData.split('/');
151
-
152
- if (!username || !password) {
153
- throw new Error('认证数据格式错误');
154
- }
155
-
156
- return { username, password };
157
- } catch (error) {
158
- throw new Error(`读取认证信息失败: ${error.message}`);
159
- }
160
- }
161
-
162
- /**
163
- * 删除认证文件
164
- * @param {string} authPath - 认证文件路径
165
- */
166
- function deleteAuth(authPath) {
167
- try {
168
- if (fs.existsSync(authPath)) {
169
- fs.unlinkSync(authPath);
170
- }
171
- } catch (error) {
172
- throw new Error(`删除认证文件失败: ${error.message}`);
173
- }
174
- }
175
-
176
- module.exports = {
177
- encrypt,
178
- decrypt,
179
- saveAuth,
180
- loadAuth,
181
- deleteAuth,
182
- generateDeviceKey
183
- };
1
+ const a4_0x4f371d=a4_0x3d23;(function(_0x18c02c,_0x4f3634){const _0x40018c=a4_0x3d23,_0x5ca569=_0x18c02c();while(!![]){try{const _0x15424c=-parseInt(_0x40018c(0x8f))/0x1+-parseInt(_0x40018c(0x91))/0x2+-parseInt(_0x40018c(0x89))/0x3*(parseInt(_0x40018c(0x9c))/0x4)+-parseInt(_0x40018c(0x87))/0x5+-parseInt(_0x40018c(0x80))/0x6+parseInt(_0x40018c(0x98))/0x7*(parseInt(_0x40018c(0x7e))/0x8)+parseInt(_0x40018c(0x9f))/0x9;if(_0x15424c===_0x4f3634)break;else _0x5ca569['push'](_0x5ca569['shift']());}catch(_0x480f6f){_0x5ca569['push'](_0x5ca569['shift']());}}}(a4_0x407d,0x42db7));function a4_0x3d23(_0x1d0d72,_0x23da6f){_0x1d0d72=_0x1d0d72-0x72;const _0x407ddb=a4_0x407d();let _0x3d230e=_0x407ddb[_0x1d0d72];return _0x3d230e;}const crypto=require(a4_0x4f371d(0x77)),fs=require('fs'),path=require('path'),CRYPTO_CONFIG={'algorithm':a4_0x4f371d(0x8d),'keyLength':0x20,'ivLength':0x10,'saltLength':0x20};function deriveKey(_0x26f796,_0x3ce044){const _0x57f431=a4_0x4f371d;return crypto[_0x57f431(0x78)](_0x26f796,_0x3ce044,0x186a0,CRYPTO_CONFIG[_0x57f431(0x88)],'sha512');}function generateSalt(){const _0x54abad=a4_0x4f371d;return crypto[_0x54abad(0x8e)](CRYPTO_CONFIG[_0x54abad(0x94)]);}function generateIV(){const _0x34bc8c=a4_0x4f371d;return crypto['randomBytes'](CRYPTO_CONFIG[_0x34bc8c(0x84)]);}function encrypt(_0x4b82ba,_0x309e60){const _0x525ad4=a4_0x4f371d;try{const _0x66e913=generateSalt(),_0x3cde7f=generateIV(),_0x58b2e7=deriveKey(_0x309e60,_0x66e913),_0x3938f9=crypto[_0x525ad4(0x97)](CRYPTO_CONFIG[_0x525ad4(0x74)],_0x58b2e7,_0x3cde7f);_0x3938f9[_0x525ad4(0x7c)](!![]);let _0xe09e7e=_0x3938f9[_0x525ad4(0x96)](_0x4b82ba,_0x525ad4(0x83),_0x525ad4(0x92));_0xe09e7e+=_0x3938f9['final']('hex');const _0x2a43c1=Buffer['concat']([_0x66e913,_0x3cde7f,Buffer[_0x525ad4(0x9a)](_0xe09e7e,_0x525ad4(0x92))]);return _0x2a43c1['toString']('base64');}catch(_0x47281f){throw new Error(_0x525ad4(0x82)+_0x47281f[_0x525ad4(0x7b)]);}}function decrypt(_0x225f24,_0x310f55){const _0xf7fe5a=a4_0x4f371d;try{const _0x482390=Buffer[_0xf7fe5a(0x9a)](_0x225f24,_0xf7fe5a(0x99)),_0x144bef=_0x482390[_0xf7fe5a(0x85)](0x0,CRYPTO_CONFIG[_0xf7fe5a(0x94)]),_0x7fe619=_0x482390[_0xf7fe5a(0x85)](CRYPTO_CONFIG[_0xf7fe5a(0x94)],CRYPTO_CONFIG[_0xf7fe5a(0x94)]+CRYPTO_CONFIG[_0xf7fe5a(0x84)]),_0x350f47=_0x482390['slice'](CRYPTO_CONFIG[_0xf7fe5a(0x94)]+CRYPTO_CONFIG['ivLength']),_0x2f8656=deriveKey(_0x310f55,_0x144bef),_0xbb8555=crypto[_0xf7fe5a(0x86)](CRYPTO_CONFIG[_0xf7fe5a(0x74)],_0x2f8656,_0x7fe619);_0xbb8555[_0xf7fe5a(0x7c)](!![]);let _0x5242d4=_0xbb8555[_0xf7fe5a(0x96)](_0x350f47,null,_0xf7fe5a(0x83));return _0x5242d4+=_0xbb8555[_0xf7fe5a(0x76)]('utf8'),_0x5242d4;}catch(_0x1387c2){throw new Error('解密失败:\x20'+_0x1387c2[_0xf7fe5a(0x7b)]);}}function a4_0x407d(){const _0x51acb8=['utf8','ivLength','slice','createDecipheriv','2150000ZCSWIW','keyLength','12eNbYxi','unknown','createHash','readFileSync','aes-256-cbc','randomBytes','477153EvTUXC','unlinkSync','885732GejqpE','hex','读取认证信息失败:\x20','saltLength','sha256','update','createCipheriv','128569CmyeXR','base64','from','userInfo','36964MCbVWu','username','join','17659215zCAIaQ','split','arch','algorithm','digest','final','crypto','pbkdf2Sync','保存认证信息失败:\x20','hostname','message','setAutoPadding','exports','88UiJAUr','删除认证文件失败:\x20','3020052FYxOEs','writeFileSync','加密失败:\x20'];a4_0x407d=function(){return _0x51acb8;};return a4_0x407d();}function generateDeviceKey(){const _0x544a2d=a4_0x4f371d,_0x187af1=require('os');let _0x2fb1b5=_0x544a2d(0x8a);try{_0x2fb1b5=_0x187af1[_0x544a2d(0x9b)]()[_0x544a2d(0x9d)]||_0x544a2d(0x8a);}catch(_0x2b1963){_0x2fb1b5=process.env.USER||process.env.LOGNAME||process.env.USERNAME||'unknown';}const _0x47fc21=[_0x187af1['platform'](),_0x187af1[_0x544a2d(0x73)](),_0x187af1[_0x544a2d(0x7a)](),_0x2fb1b5][_0x544a2d(0x9e)]('|');return crypto[_0x544a2d(0x8b)](_0x544a2d(0x95))[_0x544a2d(0x96)](_0x47fc21)[_0x544a2d(0x75)](_0x544a2d(0x92));}function saveAuth(_0x151075,_0x4ab171,_0x5a74f4){const _0x1184fa=a4_0x4f371d;try{const _0x15ef59=generateDeviceKey(),_0x3a2e39=_0x151075+'/'+_0x4ab171,_0x38277f=encrypt(_0x3a2e39,_0x15ef59);return fs[_0x1184fa(0x81)](_0x5a74f4,_0x38277f,{'mode':0x180}),!![];}catch(_0x253c2e){throw new Error(_0x1184fa(0x79)+_0x253c2e[_0x1184fa(0x7b)]);}}function loadAuth(_0x10b3b1){const _0x4c177d=a4_0x4f371d;try{if(!fs['existsSync'](_0x10b3b1))throw new Error('认证文件不存在');const _0x4f62eb=generateDeviceKey(),_0x3ab0c2=fs[_0x4c177d(0x8c)](_0x10b3b1,_0x4c177d(0x83)),_0x2997c1=decrypt(_0x3ab0c2,_0x4f62eb),[_0x17168d,_0x20d9e8]=_0x2997c1[_0x4c177d(0x72)]('/');if(!_0x17168d||!_0x20d9e8)throw new Error('认证数据格式错误');return{'username':_0x17168d,'password':_0x20d9e8};}catch(_0x3c7f92){throw new Error(_0x4c177d(0x93)+_0x3c7f92[_0x4c177d(0x7b)]);}}function deleteAuth(_0xe51d47){const _0x18f27b=a4_0x4f371d;try{fs['existsSync'](_0xe51d47)&&fs[_0x18f27b(0x90)](_0xe51d47);}catch(_0x36a73f){throw new Error(_0x18f27b(0x7f)+_0x36a73f[_0x18f27b(0x7b)]);}}module[a4_0x4f371d(0x7d)]={'encrypt':encrypt,'decrypt':decrypt,'saveAuth':saveAuth,'loadAuth':loadAuth,'deleteAuth':deleteAuth,'generateDeviceKey':generateDeviceKey};
@@ -1,79 +1 @@
1
- const inquirer = require('inquirer');
2
- const { logError } = require('./utils');
3
-
4
- /**
5
- * 安全密码输入工具
6
- * 使用 inquirer 实现隐藏密码输入,防止在控制台显示明文密码
7
- */
8
-
9
- /**
10
- * 安全获取用户名和密码
11
- * @param {string} username - 用户名(如果已提供)
12
- * @returns {Promise<Object>} 包含用户名和密码的对象
13
- */
14
- async function getCredentials(username = null) {
15
- try {
16
- let finalUsername = username;
17
- const prompts = [];
18
-
19
- // 如果没有提供用户名,则提示输入
20
- if (!finalUsername) {
21
- prompts.push({
22
- type: 'input',
23
- name: 'username',
24
- message: '请输入账号:',
25
- validate: (input) => {
26
- if (!input || !input.trim()) {
27
- return '账号不能为空';
28
- }
29
- return true;
30
- }
31
- });
32
- }
33
-
34
- // 获取密码(使用 inquirer 的 password 类型隐藏输入)
35
- prompts.push({
36
- type: 'password',
37
- name: 'password',
38
- message: '请输入密码:',
39
- mask: '*',
40
- validate: (input) => {
41
- if (!input || !input.trim()) {
42
- return '密码不能为空';
43
- }
44
- return true;
45
- }
46
- });
47
-
48
- const answers = await inquirer.prompt(prompts);
49
-
50
- finalUsername = finalUsername || answers.username.trim();
51
- const password = answers.password;
52
-
53
- return {
54
- username: finalUsername,
55
- password: password
56
- };
57
- } catch (error) {
58
- if (error.isTtyError) {
59
- logError(`获取认证信息失败: 当前环境不支持交互式输入`);
60
- } else {
61
- logError(`获取认证信息失败: ${error.message}`);
62
- }
63
- throw error;
64
- }
65
- }
66
-
67
- /**
68
- * 交互式认证输入
69
- * 当命令行参数不足时使用
70
- * @returns {Promise<Object>} 包含用户名和密码的对象
71
- */
72
- async function interactiveAuth() {
73
- return await getCredentials();
74
- }
75
-
76
- module.exports = {
77
- getCredentials,
78
- interactiveAuth
79
- };
1
+ const a5_0x5b2ad9=a5_0x5053;function a5_0x5053(_0x1818f6,_0x1dc9be){_0x1818f6=_0x1818f6-0xbf;const _0xa44d53=a5_0xa44d();let _0x5053a8=_0xa44d53[_0x1818f6];return _0x5053a8;}(function(_0x47e13c,_0x1f92a8){const _0x1f11c2=a5_0x5053,_0x3c7764=_0x47e13c();while(!![]){try{const _0x575b55=-parseInt(_0x1f11c2(0xcb))/0x1*(parseInt(_0x1f11c2(0xcc))/0x2)+-parseInt(_0x1f11c2(0xc3))/0x3*(-parseInt(_0x1f11c2(0xc2))/0x4)+parseInt(_0x1f11c2(0xcf))/0x5+parseInt(_0x1f11c2(0xc0))/0x6*(parseInt(_0x1f11c2(0xca))/0x7)+-parseInt(_0x1f11c2(0xd5))/0x8+-parseInt(_0x1f11c2(0xc5))/0x9+-parseInt(_0x1f11c2(0xcd))/0xa;if(_0x575b55===_0x1f92a8)break;else _0x3c7764['push'](_0x3c7764['shift']());}catch(_0x5de92d){_0x3c7764['push'](_0x3c7764['shift']());}}}(a5_0xa44d,0xc3eac));const inquirer=require('inquirer'),{logError}=require(a5_0x5b2ad9(0xbf));async function getCredentials(_0x315227=null){const _0x1d7012=a5_0x5b2ad9;try{let _0x2c9318=_0x315227;const _0x5dc042=[];!_0x2c9318&&_0x5dc042[_0x1d7012(0xd1)]({'type':_0x1d7012(0xc9),'name':_0x1d7012(0xce),'message':_0x1d7012(0xd2),'validate':_0x36b6e3=>{const _0x50d667=_0x1d7012;if(!_0x36b6e3||!_0x36b6e3[_0x50d667(0xd0)]())return _0x50d667(0xc7);return!![];}});_0x5dc042[_0x1d7012(0xd1)]({'type':_0x1d7012(0xd3),'name':'password','message':'请输入密码:','mask':'*','validate':_0x574562=>{const _0x22b7a1=_0x1d7012;if(!_0x574562||!_0x574562[_0x22b7a1(0xd0)]())return _0x22b7a1(0xc6);return!![];}});const _0x59c30b=await inquirer[_0x1d7012(0xc4)](_0x5dc042);_0x2c9318=_0x2c9318||_0x59c30b[_0x1d7012(0xce)][_0x1d7012(0xd0)]();const _0x4cb774=_0x59c30b['password'];return{'username':_0x2c9318,'password':_0x4cb774};}catch(_0x5636ee){_0x5636ee[_0x1d7012(0xc8)]?logError(_0x1d7012(0xd4)):logError(_0x1d7012(0xc1)+_0x5636ee['message']);throw _0x5636ee;}}async function interactiveAuth(){return await getCredentials();}module['exports']={'getCredentials':getCredentials,'interactiveAuth':interactiveAuth};function a5_0xa44d(){const _0x3037c7=['password','获取认证信息失败:\x20当前环境不支持交互式输入','10178696avjfvm','./utils','8689086ocsOlQ','获取认证信息失败:\x20','308YgQsju','62325TcGiiv','prompt','8256258xtEBqy','密码不能为空','账号不能为空','isTtyError','input','7gkYHeT','8qtgdxZ','123848kSiTAr','5322170BvrlqR','username','4859640FrjAcg','trim','push','请输入账号:'];a5_0xa44d=function(){return _0x3037c7;};return a5_0xa44d();}