@helixlife-ai/xiantao 0.1.7 → 0.1.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/README.md +0 -4
- package/dist/lib/xiantao-auth.js +19 -23
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -44,10 +44,8 @@ For machine callers, use `xt tool exec`, keep `--json`, pass an explicit profile
|
|
|
44
44
|
### Auth
|
|
45
45
|
|
|
46
46
|
- `xt login`
|
|
47
|
-
- `xt bind`
|
|
48
47
|
- `xt status`
|
|
49
48
|
- `xt logout`
|
|
50
|
-
- `xt auth bind`
|
|
51
49
|
- `xt tool login`
|
|
52
50
|
|
|
53
51
|
### Tool Run
|
|
@@ -75,8 +73,6 @@ For the common Xiantao tool product, `tool search`, `tool inspect`, `tool run`,
|
|
|
75
73
|
|
|
76
74
|
When resolving tools from `--toolProductUuid`, the CLI caches the `/tool/menus?is_all=1` result locally for 12 hours per `profile + toolProductUuid` to avoid repeated full-menu fetches.
|
|
77
75
|
|
|
78
|
-
For remote-agent flows where the Xiantao web login callback cannot hit the machine running the CLI, use `xt bind --xiantao-token <token> --profile openclaw`. The bind command creates the upload auth session, calls the same `/user/skills/bind_user` API directly, waits for confirmation, and persists both the upload token and the Xiantao token locally. If you already created the auth session elsewhere, you can reuse it with `xt bind --auth-key <auth_key> --token-key <token_key> --xiantao-token <token>`.
|
|
79
|
-
|
|
80
76
|
## Development
|
|
81
77
|
|
|
82
78
|
```bash
|
package/dist/lib/xiantao-auth.js
CHANGED
|
@@ -3,7 +3,7 @@ import { AUTH_BIND_ENDPOINT, PASSPORT_JUMP_ENDPOINT } from './constants.js';
|
|
|
3
3
|
import { openUrl } from './open-url.js';
|
|
4
4
|
import { XtzError } from './errors.js';
|
|
5
5
|
import { requestJson } from './http.js';
|
|
6
|
-
import { loadXiantaoToken, requireXiantaoToken, saveXiantaoToken } from './storage.js';
|
|
6
|
+
import { getXiantaoTokenPath, loadXiantaoToken, requireXiantaoToken, saveXiantaoToken } from './storage.js';
|
|
7
7
|
export async function getXiantaoAuthContext(agent, tokenOverride) {
|
|
8
8
|
const token = tokenOverride?.trim() || process.env.XIANTAO_TOKEN?.trim() || await requireXiantaoToken(agent);
|
|
9
9
|
return { agent, token };
|
|
@@ -29,34 +29,24 @@ export async function loginXiantao(agent) {
|
|
|
29
29
|
tokenPath,
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
-
export async function bindUserWithXiantaoToken(agent, authKey, token) {
|
|
33
|
-
await requestJson(AUTH_BIND_ENDPOINT, {
|
|
34
|
-
body: JSON.stringify({ auth_key: authKey }),
|
|
35
|
-
headers: {
|
|
36
|
-
Authorization: `Bearer ${token}`,
|
|
37
|
-
'Content-Type': 'application/json',
|
|
38
|
-
origin: 'https://www.helixlife.net',
|
|
39
|
-
platform: 'pc',
|
|
40
|
-
referer: 'https://www.helixlife.net/',
|
|
41
|
-
source: 'PC',
|
|
42
|
-
},
|
|
43
|
-
method: 'POST',
|
|
44
|
-
}, { agent, tokenKind: 'xiantao' });
|
|
45
|
-
const tokenPath = await saveXiantaoToken(agent, token);
|
|
46
|
-
return {
|
|
47
|
-
browserOpened: false,
|
|
48
|
-
reused: true,
|
|
49
|
-
token,
|
|
50
|
-
tokenPath,
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
32
|
export async function bindUserWithStoredXiantaoToken(agent, authKey) {
|
|
54
33
|
const auth = await loadXiantaoAuthContext(agent);
|
|
55
34
|
if (!auth) {
|
|
56
35
|
return undefined;
|
|
57
36
|
}
|
|
58
37
|
try {
|
|
59
|
-
|
|
38
|
+
await requestJson(AUTH_BIND_ENDPOINT, {
|
|
39
|
+
body: JSON.stringify({ auth_key: authKey }),
|
|
40
|
+
headers: {
|
|
41
|
+
Authorization: `Bearer ${auth.token}`,
|
|
42
|
+
'Content-Type': 'application/json',
|
|
43
|
+
origin: 'https://www.helixlife.net',
|
|
44
|
+
platform: 'pc',
|
|
45
|
+
referer: 'https://www.helixlife.net/',
|
|
46
|
+
source: 'PC',
|
|
47
|
+
},
|
|
48
|
+
method: 'POST',
|
|
49
|
+
}, { agent, tokenKind: 'xiantao' });
|
|
60
50
|
}
|
|
61
51
|
catch (error) {
|
|
62
52
|
if (error instanceof XtzError && error.message.includes('仙桃网页授权已过期或无效')) {
|
|
@@ -64,6 +54,12 @@ export async function bindUserWithStoredXiantaoToken(agent, authKey) {
|
|
|
64
54
|
}
|
|
65
55
|
throw error;
|
|
66
56
|
}
|
|
57
|
+
return {
|
|
58
|
+
browserOpened: false,
|
|
59
|
+
reused: true,
|
|
60
|
+
token: auth.token,
|
|
61
|
+
tokenPath: getXiantaoTokenPath(agent),
|
|
62
|
+
};
|
|
67
63
|
}
|
|
68
64
|
async function createLoginSession() {
|
|
69
65
|
let resolveToken;
|