@helixlife-ai/xiantao 0.1.9 → 0.1.10
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/dist/lib/errors.js +2 -2
- package/package.json +1 -1
- package/dist/commands/auth/bind.js +0 -53
- package/dist/commands/bind.js +0 -3
package/dist/lib/errors.js
CHANGED
|
@@ -25,9 +25,9 @@ export async function raiseApiError(payload, options = {}) {
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
if (tokenKind === 'xiantao') {
|
|
28
|
-
throw new XtzError('
|
|
28
|
+
throw new XtzError('您的授权已过期或无效,请重新完成授权。。');
|
|
29
29
|
}
|
|
30
|
-
throw new XtzError('
|
|
30
|
+
throw new XtzError('您的授权已过期或无效,请重新完成授权。');
|
|
31
31
|
}
|
|
32
32
|
if (message.includes('无权限') || message.includes('权限')) {
|
|
33
33
|
throw new XtzError('需购买仙桃高级版 https://www.xiantaozi.com/');
|
package/package.json
CHANGED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { Flags } from '@oclif/core';
|
|
2
|
-
import { XtzCommand } from '../../base-command.js';
|
|
3
|
-
import { loginAuth, waitForAuthorizedToken } from '../../lib/auth.js';
|
|
4
|
-
import { globalFlags } from '../../lib/flags.js';
|
|
5
|
-
import { bindUserWithXiantaoToken } from '../../lib/xiantao-auth.js';
|
|
6
|
-
import { getTokenPath, getXiantaoTokenPath, loadXiantaoToken, saveToken } from '../../lib/storage.js';
|
|
7
|
-
export default class AuthBind extends XtzCommand {
|
|
8
|
-
static description = 'Bind login remotely with a Xiantao web token without the localhost callback flow';
|
|
9
|
-
static flags = {
|
|
10
|
-
...globalFlags,
|
|
11
|
-
'auth-key': Flags.string({
|
|
12
|
-
char: 'k',
|
|
13
|
-
description: 'Existing auth key returned by the upload authorization flow',
|
|
14
|
-
}),
|
|
15
|
-
'token-key': Flags.string({
|
|
16
|
-
description: 'Existing upload token key paired with --auth-key',
|
|
17
|
-
}),
|
|
18
|
-
'xiantao-token': Flags.string({
|
|
19
|
-
description: 'Bearer token for api.helixlife.net xiantao APIs; falls back to XIANTAO_TOKEN or the stored Xiantao web token',
|
|
20
|
-
}),
|
|
21
|
-
};
|
|
22
|
-
async run() {
|
|
23
|
-
this.warnIfLegacyAuthCommand();
|
|
24
|
-
const { flags } = await this.parse(AuthBind);
|
|
25
|
-
const agent = await this.getProfile(flags.profile);
|
|
26
|
-
const token = flags['xiantao-token']?.trim() || process.env.XIANTAO_TOKEN?.trim() || await loadXiantaoToken(agent);
|
|
27
|
-
if (!token) {
|
|
28
|
-
this.error(`未找到 ${agent} 的仙桃网页 token,请传 --xiantao-token、设置 XIANTAO_TOKEN,或先准备 ${getXiantaoTokenPath(agent)}`, { exit: 1 });
|
|
29
|
-
}
|
|
30
|
-
const auth = flags['auth-key']
|
|
31
|
-
? {
|
|
32
|
-
authKey: flags['auth-key'],
|
|
33
|
-
token: flags['token-key']?.trim(),
|
|
34
|
-
tokenPath: getTokenPath(agent),
|
|
35
|
-
}
|
|
36
|
-
: await loginAuth(agent, false);
|
|
37
|
-
if (!auth.token) {
|
|
38
|
-
this.error('传 --auth-key 时必须同时传 --token-key', { exit: 1 });
|
|
39
|
-
}
|
|
40
|
-
if (flags['auth-key']) {
|
|
41
|
-
await saveToken(agent, auth.token);
|
|
42
|
-
}
|
|
43
|
-
const result = await bindUserWithXiantaoToken(agent, auth.authKey, token);
|
|
44
|
-
await waitForAuthorizedToken(auth.token);
|
|
45
|
-
this.print(flags, {
|
|
46
|
-
agent,
|
|
47
|
-
auth_key: auth.authKey,
|
|
48
|
-
bound: true,
|
|
49
|
-
token_path: auth.tokenPath,
|
|
50
|
-
xiantao_token_path: result.tokenPath,
|
|
51
|
-
}, `profile: ${agent}\nbound: true\nauth_key: ${auth.authKey}\ntoken: ${auth.tokenPath}\nxiantao_token: ${result.tokenPath}`);
|
|
52
|
-
}
|
|
53
|
-
}
|
package/dist/commands/bind.js
DELETED