heibai 1.0.8
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/.claude/settings.local.json +10 -0
- package/README.md +89 -0
- package/bin/cli.js +1140 -0
- package/bin/heibai.js +24 -0
- package/bin/xuqiu +31 -0
- package/code-validator.js +486 -0
- package/package.json +38 -0
package/bin/heibai.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { spawn } = require('child_process');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
|
|
7
|
+
(async () => {
|
|
8
|
+
const args = process.argv.slice(2);
|
|
9
|
+
const env = { ...process.env };
|
|
10
|
+
|
|
11
|
+
// 使用 npx 直接调用可执行,以便无需本地依赖即可工作
|
|
12
|
+
const isWin = process.platform === 'win32';
|
|
13
|
+
const cmd = 'npx';
|
|
14
|
+
const cmdArgs = ['-y', 'copilot-api@latest', ...args];
|
|
15
|
+
|
|
16
|
+
const p = spawn(cmd, cmdArgs, { stdio: 'inherit', env, shell: isWin });
|
|
17
|
+
p.on('close', (code) => process.exit(code));
|
|
18
|
+
p.on('error', (err) => {
|
|
19
|
+
console.error('启动失败: ' + err.message);
|
|
20
|
+
process.exit(1);
|
|
21
|
+
});
|
|
22
|
+
})();
|
|
23
|
+
|
|
24
|
+
|
package/bin/xuqiu
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
我需要的逻辑 :
|
|
2
|
+
当用户 npm install -g heibai-claude-code-gpt5
|
|
3
|
+
然后 执行 npx heibai-setup
|
|
4
|
+
|
|
5
|
+
会询问端口那时候 就自动强制全局 默认。
|
|
6
|
+
|
|
7
|
+
heibai-api 执行
|
|
8
|
+
|
|
9
|
+
PS C:\Users\dell> heibai-api
|
|
10
|
+
[上午4:13:58] A wrapper around GitHub Copilot API to make it OpenAI compatible, making it usable for other tools. (copilot-api)
|
|
11
|
+
|
|
12
|
+
USAGE copilot-api auth|start|check-usage|debug
|
|
13
|
+
|
|
14
|
+
COMMANDS
|
|
15
|
+
|
|
16
|
+
auth Run GitHub auth flow without running the server
|
|
17
|
+
start Start the Copilot API server
|
|
18
|
+
check-usage Show current GitHub Copilot usage/quota information
|
|
19
|
+
debug Print debug information about the application
|
|
20
|
+
|
|
21
|
+
Use copilot-api <command> --help for more information about a command.
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
ERROR No command specified. 上午4:13:58
|
|
25
|
+
|
|
26
|
+
PS C:\Users\dell>
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
结果不需要输出。只需要保证heibai-api 可以使用即可。
|
|
30
|
+
|
|
31
|
+
以及模式1,模式2 整体流程没问题。
|
|
@@ -0,0 +1,486 @@
|
|
|
1
|
+
const https = require('https');
|
|
2
|
+
const chalk = require('chalk');
|
|
3
|
+
const { HttpsProxyAgent } = require('https-proxy-agent');
|
|
4
|
+
|
|
5
|
+
// LeanCloud 配置
|
|
6
|
+
const APP_ID = 'Thd1b2VQErFyM7KwtvG1oXLN-MdYXbMMI';
|
|
7
|
+
const APP_KEY = 'YqcoM2zK0nCqxwvvhkmRRQEQ';
|
|
8
|
+
const MASTER_KEY = 'QW7tIbFVF1ZEKlS2cuJ1PoQ2';
|
|
9
|
+
const SERVER_URL = 'thd1b2vq.api.lncldglobal.com';
|
|
10
|
+
|
|
11
|
+
function getProxyAgent() {
|
|
12
|
+
try {
|
|
13
|
+
const proxyUrl = process.env.HTTPS_PROXY || process.env.HTTP_PROXY || '';
|
|
14
|
+
if (proxyUrl) return new HttpsProxyAgent(proxyUrl);
|
|
15
|
+
} catch (e) {}
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
class CodeValidator {
|
|
20
|
+
constructor() {
|
|
21
|
+
this.tableName = 'cc';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// 查询兑换码
|
|
25
|
+
async queryCode(ma) {
|
|
26
|
+
return new Promise((resolve, reject) => {
|
|
27
|
+
const cleanCode = ma.trim();
|
|
28
|
+
|
|
29
|
+
// 首先尝试精确匹配
|
|
30
|
+
const exactQueryPath = `/1.1/classes/${this.tableName}?where=${encodeURIComponent(JSON.stringify({ma: cleanCode}))}`;
|
|
31
|
+
|
|
32
|
+
const queryOptions = {
|
|
33
|
+
hostname: SERVER_URL,
|
|
34
|
+
port: 443,
|
|
35
|
+
path: exactQueryPath,
|
|
36
|
+
method: 'GET',
|
|
37
|
+
agent: getProxyAgent(),
|
|
38
|
+
headers: {
|
|
39
|
+
'X-LC-Id': APP_ID,
|
|
40
|
+
'X-LC-Key': `${MASTER_KEY},master`,
|
|
41
|
+
'Content-Type': 'application/json',
|
|
42
|
+
'User-Agent': 'LeanCloud-JS-SDK/4.15.2'
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const req = https.request(queryOptions, (res) => {
|
|
47
|
+
let data = '';
|
|
48
|
+
|
|
49
|
+
res.on('data', (chunk) => {
|
|
50
|
+
data += chunk;
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
res.on('end', () => {
|
|
54
|
+
if (res.statusCode === 200) {
|
|
55
|
+
try {
|
|
56
|
+
const result = JSON.parse(data);
|
|
57
|
+
|
|
58
|
+
if (result.results && result.results.length > 0) {
|
|
59
|
+
resolve(result.results);
|
|
60
|
+
} else {
|
|
61
|
+
// 精确匹配失败,尝试获取所有记录进行模糊匹配
|
|
62
|
+
this.queryAllAndMatch(cleanCode).then(resolve).catch(reject);
|
|
63
|
+
}
|
|
64
|
+
} catch (parseError) {
|
|
65
|
+
reject(new Error(`解析响应失败: ${parseError.message}`));
|
|
66
|
+
}
|
|
67
|
+
} else {
|
|
68
|
+
reject(new Error(`查询失败: HTTP ${res.statusCode} - ${data}`));
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
req.on('error', (error) => {
|
|
74
|
+
reject(new Error(`请求失败: ${error.message}`));
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
req.setTimeout(10000, () => {
|
|
78
|
+
req.destroy();
|
|
79
|
+
reject(new Error('请求超时'));
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
req.end();
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// 获取所有记录并进行模糊匹配
|
|
87
|
+
async queryAllAndMatch(targetCode) {
|
|
88
|
+
return new Promise((resolve, reject) => {
|
|
89
|
+
const allQueryPath = `/1.1/classes/${this.tableName}`;
|
|
90
|
+
|
|
91
|
+
const options = {
|
|
92
|
+
hostname: SERVER_URL,
|
|
93
|
+
port: 443,
|
|
94
|
+
path: allQueryPath,
|
|
95
|
+
method: 'GET',
|
|
96
|
+
agent: getProxyAgent(),
|
|
97
|
+
headers: {
|
|
98
|
+
'X-LC-Id': APP_ID,
|
|
99
|
+
'X-LC-Key': `${MASTER_KEY},master`,
|
|
100
|
+
'Content-Type': 'application/json',
|
|
101
|
+
'User-Agent': 'LeanCloud-JS-SDK/4.15.2'
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const req = https.request(options, (res) => {
|
|
106
|
+
let data = '';
|
|
107
|
+
|
|
108
|
+
res.on('data', (chunk) => {
|
|
109
|
+
data += chunk;
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
res.on('end', () => {
|
|
113
|
+
if (res.statusCode === 200) {
|
|
114
|
+
try {
|
|
115
|
+
const result = JSON.parse(data);
|
|
116
|
+
|
|
117
|
+
if (result.results) {
|
|
118
|
+
// 查找匹配的记录 - 去除所有空格和换行符
|
|
119
|
+
const matchedResults = result.results.filter(item => {
|
|
120
|
+
const itemCode = (item.ma || '').replace(/\s+/g, '');
|
|
121
|
+
const cleanTargetCode = targetCode.replace(/\s+/g, '');
|
|
122
|
+
return itemCode === cleanTargetCode;
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
resolve(matchedResults);
|
|
126
|
+
} else {
|
|
127
|
+
resolve([]);
|
|
128
|
+
}
|
|
129
|
+
} catch (parseError) {
|
|
130
|
+
reject(new Error(`解析响应失败: ${parseError.message}`));
|
|
131
|
+
}
|
|
132
|
+
} else {
|
|
133
|
+
reject(new Error(`查询失败: HTTP ${res.statusCode} - ${data}`));
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
req.on('error', (error) => {
|
|
139
|
+
reject(new Error(`请求失败: ${error.message}`));
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
req.setTimeout(10000, () => {
|
|
143
|
+
req.destroy();
|
|
144
|
+
reject(new Error('请求超时'));
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
req.end();
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// 更新兑换码模型字段
|
|
152
|
+
async updateModelField(objectId, modelValue) {
|
|
153
|
+
return new Promise((resolve, reject) => {
|
|
154
|
+
const updatePath = `/1.1/classes/${this.tableName}/${objectId}`;
|
|
155
|
+
const updateData = JSON.stringify({ model: modelValue });
|
|
156
|
+
|
|
157
|
+
const options = {
|
|
158
|
+
hostname: SERVER_URL,
|
|
159
|
+
port: 443,
|
|
160
|
+
path: updatePath,
|
|
161
|
+
method: 'PUT',
|
|
162
|
+
agent: getProxyAgent(),
|
|
163
|
+
headers: {
|
|
164
|
+
'X-LC-Id': APP_ID,
|
|
165
|
+
'X-LC-Key': `${MASTER_KEY},master`,
|
|
166
|
+
'Content-Type': 'application/json',
|
|
167
|
+
'Content-Length': Buffer.byteLength(updateData),
|
|
168
|
+
'User-Agent': 'LeanCloud-JS-SDK/4.15.2'
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
const req = https.request(options, (res) => {
|
|
173
|
+
let data = '';
|
|
174
|
+
|
|
175
|
+
res.on('data', (chunk) => {
|
|
176
|
+
data += chunk;
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
res.on('end', () => {
|
|
180
|
+
if (res.statusCode === 200) {
|
|
181
|
+
try {
|
|
182
|
+
const result = JSON.parse(data);
|
|
183
|
+
resolve(result);
|
|
184
|
+
} catch (parseError) {
|
|
185
|
+
reject(new Error(`解析响应失败: ${parseError.message}`));
|
|
186
|
+
}
|
|
187
|
+
} else {
|
|
188
|
+
reject(new Error(`模型更新失败: HTTP ${res.statusCode} - ${data}`));
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
req.on('error', (error) => {
|
|
194
|
+
reject(new Error(`请求失败: ${error.message}`));
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
req.setTimeout(10000, () => {
|
|
198
|
+
req.destroy();
|
|
199
|
+
reject(new Error('请求超时'));
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
req.write(updateData);
|
|
203
|
+
req.end();
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// 更新兑换码使用次数
|
|
208
|
+
async updateUsageCount(objectId, newCount) {
|
|
209
|
+
return new Promise((resolve, reject) => {
|
|
210
|
+
const updatePath = `/1.1/classes/${this.tableName}/${objectId}`;
|
|
211
|
+
const updateData = JSON.stringify({ shu: newCount });
|
|
212
|
+
|
|
213
|
+
const options = {
|
|
214
|
+
hostname: SERVER_URL,
|
|
215
|
+
port: 443,
|
|
216
|
+
path: updatePath,
|
|
217
|
+
method: 'PUT',
|
|
218
|
+
agent: getProxyAgent(),
|
|
219
|
+
headers: {
|
|
220
|
+
'X-LC-Id': APP_ID,
|
|
221
|
+
'X-LC-Key': `${MASTER_KEY},master`,
|
|
222
|
+
'Content-Type': 'application/json',
|
|
223
|
+
'Content-Length': Buffer.byteLength(updateData),
|
|
224
|
+
'User-Agent': 'LeanCloud-JS-SDK/4.15.2'
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
const req = https.request(options, (res) => {
|
|
229
|
+
let data = '';
|
|
230
|
+
|
|
231
|
+
res.on('data', (chunk) => {
|
|
232
|
+
data += chunk;
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
res.on('end', () => {
|
|
236
|
+
if (res.statusCode === 200) {
|
|
237
|
+
try {
|
|
238
|
+
const result = JSON.parse(data);
|
|
239
|
+
resolve(result);
|
|
240
|
+
} catch (parseError) {
|
|
241
|
+
reject(new Error(`解析响应失败: ${parseError.message}`));
|
|
242
|
+
}
|
|
243
|
+
} else {
|
|
244
|
+
reject(new Error(`更新失败: HTTP ${res.statusCode} - ${data}`));
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
req.on('error', (error) => {
|
|
250
|
+
reject(new Error(`请求失败: ${error.message}`));
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
req.setTimeout(10000, () => {
|
|
254
|
+
req.destroy();
|
|
255
|
+
reject(new Error('请求超时'));
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
req.write(updateData);
|
|
259
|
+
req.end();
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// 更新设备信息(mac、ip、diyi参数)
|
|
264
|
+
async updateDeviceInfo(objectId, deviceInfo) {
|
|
265
|
+
return new Promise((resolve, reject) => {
|
|
266
|
+
const updatePath = `/1.1/classes/${this.tableName}/${objectId}`;
|
|
267
|
+
const updateData = JSON.stringify(deviceInfo);
|
|
268
|
+
|
|
269
|
+
const options = {
|
|
270
|
+
hostname: SERVER_URL,
|
|
271
|
+
port: 443,
|
|
272
|
+
path: updatePath,
|
|
273
|
+
method: 'PUT',
|
|
274
|
+
agent: getProxyAgent(),
|
|
275
|
+
headers: {
|
|
276
|
+
'X-LC-Id': APP_ID,
|
|
277
|
+
'X-LC-Key': `${MASTER_KEY},master`,
|
|
278
|
+
'Content-Type': 'application/json',
|
|
279
|
+
'Content-Length': Buffer.byteLength(updateData),
|
|
280
|
+
'User-Agent': 'LeanCloud-JS-SDK/4.15.2'
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
const req = https.request(options, (res) => {
|
|
285
|
+
let data = '';
|
|
286
|
+
|
|
287
|
+
res.on('data', (chunk) => {
|
|
288
|
+
data += chunk;
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
res.on('end', () => {
|
|
292
|
+
if (res.statusCode === 200) {
|
|
293
|
+
try {
|
|
294
|
+
const result = JSON.parse(data);
|
|
295
|
+
resolve(result);
|
|
296
|
+
} catch (parseError) {
|
|
297
|
+
reject(new Error(`解析响应失败: ${parseError.message}`));
|
|
298
|
+
}
|
|
299
|
+
} else {
|
|
300
|
+
reject(new Error(`设备信息更新失败: HTTP ${res.statusCode} - ${data}`));
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
req.on('error', (error) => {
|
|
306
|
+
reject(new Error(`请求失败: ${error.message}`));
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
req.setTimeout(10000, () => {
|
|
310
|
+
req.destroy();
|
|
311
|
+
reject(new Error('请求超时'));
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
req.write(updateData);
|
|
315
|
+
req.end();
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// 获取兑换码的diyi字段
|
|
320
|
+
async getCodeDiyi(objectId) {
|
|
321
|
+
return new Promise((resolve, reject) => {
|
|
322
|
+
const queryPath = `/1.1/classes/${this.tableName}/${objectId}`;
|
|
323
|
+
|
|
324
|
+
const options = {
|
|
325
|
+
hostname: SERVER_URL,
|
|
326
|
+
port: 443,
|
|
327
|
+
path: queryPath,
|
|
328
|
+
method: 'GET',
|
|
329
|
+
agent: getProxyAgent(),
|
|
330
|
+
headers: {
|
|
331
|
+
'X-LC-Id': APP_ID,
|
|
332
|
+
'X-LC-Key': `${MASTER_KEY},master`,
|
|
333
|
+
'Content-Type': 'application/json',
|
|
334
|
+
'User-Agent': 'LeanCloud-JS-SDK/4.15.2'
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
|
|
338
|
+
const req = https.request(options, (res) => {
|
|
339
|
+
let data = '';
|
|
340
|
+
|
|
341
|
+
res.on('data', (chunk) => {
|
|
342
|
+
data += chunk;
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
res.on('end', () => {
|
|
346
|
+
if (res.statusCode === 200) {
|
|
347
|
+
try {
|
|
348
|
+
const result = JSON.parse(data);
|
|
349
|
+
resolve(result.diyi || null);
|
|
350
|
+
} catch (parseError) {
|
|
351
|
+
reject(new Error(`解析响应失败: ${parseError.message}`));
|
|
352
|
+
}
|
|
353
|
+
} else {
|
|
354
|
+
reject(new Error(`查询失败: HTTP ${res.statusCode} - ${data}`));
|
|
355
|
+
}
|
|
356
|
+
});
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
req.on('error', (error) => {
|
|
360
|
+
reject(new Error(`请求失败: ${error.message}`));
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
req.setTimeout(10000, () => {
|
|
364
|
+
req.destroy();
|
|
365
|
+
reject(new Error('请求超时'));
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
req.end();
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
async validateCode(ma) {
|
|
373
|
+
try {
|
|
374
|
+
// 清理输入的兑换码,去除前后空白和换行符
|
|
375
|
+
const cleanCode = ma.trim();
|
|
376
|
+
console.log(`正在验证兑换码: ${cleanCode}`);
|
|
377
|
+
|
|
378
|
+
// 查询兑换码
|
|
379
|
+
const results = await this.queryCode(cleanCode);
|
|
380
|
+
|
|
381
|
+
if (results.length === 0) {
|
|
382
|
+
return {
|
|
383
|
+
valid: false,
|
|
384
|
+
message: '兑换码不存在,请检查后重试或联系客服'
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
const codeObject = results[0];
|
|
389
|
+
const guoqitimeData = codeObject.guoqitime;
|
|
390
|
+
|
|
391
|
+
// 处理时间格式 - LeanCloud返回的可能是对象格式
|
|
392
|
+
let expireTime;
|
|
393
|
+
if (guoqitimeData && guoqitimeData.iso) {
|
|
394
|
+
expireTime = new Date(guoqitimeData.iso);
|
|
395
|
+
} else if (guoqitimeData) {
|
|
396
|
+
expireTime = new Date(guoqitimeData);
|
|
397
|
+
} else {
|
|
398
|
+
return {
|
|
399
|
+
valid: false,
|
|
400
|
+
message: '兑换码数据异常,请联系客服'
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
const currentTime = new Date();
|
|
405
|
+
const usageCount = codeObject.shu || 0;
|
|
406
|
+
|
|
407
|
+
// 检查是否过期 - 严格验证
|
|
408
|
+
if (currentTime > expireTime) {
|
|
409
|
+
return {
|
|
410
|
+
valid: false,
|
|
411
|
+
message: '体验已过期,联系客服'
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
// 验证成功,增加使用次数
|
|
416
|
+
const newUsageCount = usageCount + 1;
|
|
417
|
+
|
|
418
|
+
try {
|
|
419
|
+
await this.updateUsageCount(codeObject.objectId, newUsageCount);
|
|
420
|
+
console.log(chalk.blue(`数据库使用次数已更新: ${usageCount} -> ${newUsageCount}`));
|
|
421
|
+
} catch (updateError) {
|
|
422
|
+
console.log(chalk.yellow(`⚠️ 使用次数更新失败: ${updateError.message}`));
|
|
423
|
+
// 即使更新失败,仍然允许验证通过
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
return {
|
|
427
|
+
valid: true,
|
|
428
|
+
message: '验证成功',
|
|
429
|
+
data: {
|
|
430
|
+
code: cleanCode,
|
|
431
|
+
expireTime: expireTime,
|
|
432
|
+
usageCount: newUsageCount,
|
|
433
|
+
objectId: codeObject.objectId,
|
|
434
|
+
url: codeObject.url || null, // 添加URL字段
|
|
435
|
+
key: codeObject.key || null // 添加key字段
|
|
436
|
+
}
|
|
437
|
+
};
|
|
438
|
+
|
|
439
|
+
} catch (error) {
|
|
440
|
+
console.error('验证兑换码时发生错误:', error);
|
|
441
|
+
|
|
442
|
+
return {
|
|
443
|
+
valid: false,
|
|
444
|
+
message: '验证失败,请检查网络连接或联系客服'
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
async getCodeInfo(ma) {
|
|
450
|
+
try {
|
|
451
|
+
const results = await this.queryCode(ma);
|
|
452
|
+
|
|
453
|
+
if (results.length > 0) {
|
|
454
|
+
const codeObject = results[0];
|
|
455
|
+
const guoqitimeData = codeObject.guoqitime;
|
|
456
|
+
|
|
457
|
+
// 处理时间格式
|
|
458
|
+
let expireTime;
|
|
459
|
+
if (guoqitimeData && guoqitimeData.iso) {
|
|
460
|
+
expireTime = new Date(guoqitimeData.iso);
|
|
461
|
+
} else if (guoqitimeData) {
|
|
462
|
+
expireTime = new Date(guoqitimeData);
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
return {
|
|
466
|
+
code: codeObject.ma,
|
|
467
|
+
expireTime: expireTime,
|
|
468
|
+
usageCount: codeObject.shu || 0,
|
|
469
|
+
createdAt: codeObject.createdAt ? new Date(codeObject.createdAt) : null,
|
|
470
|
+
updatedAt: codeObject.updatedAt ? new Date(codeObject.updatedAt) : null,
|
|
471
|
+
objectId: codeObject.objectId,
|
|
472
|
+
url: codeObject.url || null, // 添加URL字段
|
|
473
|
+
key: codeObject.key || null // 添加key字段
|
|
474
|
+
};
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
return null;
|
|
478
|
+
|
|
479
|
+
} catch (error) {
|
|
480
|
+
console.error('获取兑换码信息失败:', error);
|
|
481
|
+
return null;
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
module.exports = CodeValidator;
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "heibai",
|
|
3
|
+
"version": "1.0.8",
|
|
4
|
+
"description": "AI助手快速配置工具,支持代理设置 (Windows/Mac)",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"heibai-setup": "./bin/cli.js",
|
|
8
|
+
"heibai-api": "./bin/heibai.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"start": "node bin/cli.js"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"ai",
|
|
15
|
+
"assistant",
|
|
16
|
+
"code",
|
|
17
|
+
"proxy",
|
|
18
|
+
"setup",
|
|
19
|
+
"cli",
|
|
20
|
+
"heibai"
|
|
21
|
+
],
|
|
22
|
+
"author": "Your Name",
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"axios": "^1.6.0",
|
|
26
|
+
"chalk": "^4.1.2",
|
|
27
|
+
"https-proxy-agent": "^7.0.6",
|
|
28
|
+
"inquirer": "^8.2.7",
|
|
29
|
+
"leancloud-storage": "^4.15.2"
|
|
30
|
+
},
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=18.0.0"
|
|
33
|
+
},
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "https://github.com/yourusername/heibai-claude-code-gpt5.git"
|
|
37
|
+
}
|
|
38
|
+
}
|