@yulailai/openclaw-plugin-self-growth 3.1.18 → 3.1.20
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/auth-client.js +26 -0
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/auth-client.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// 认证客户端 - 获取和刷新 JWT token
|
|
2
2
|
import * as fs from 'fs/promises';
|
|
3
3
|
import * as path from 'path';
|
|
4
|
+
import { loadActivation } from './payment';
|
|
4
5
|
let _cache = null;
|
|
5
6
|
export function getCachedToken() {
|
|
6
7
|
return _cache;
|
|
@@ -17,6 +18,31 @@ export async function loginAndGetToken(serverUrl, email, basePath) {
|
|
|
17
18
|
}
|
|
18
19
|
}
|
|
19
20
|
catch { }
|
|
21
|
+
// 用 payment.json 里的 token 验证
|
|
22
|
+
try {
|
|
23
|
+
const activation = await loadActivation(basePath);
|
|
24
|
+
const token = activation?.license;
|
|
25
|
+
if (token) {
|
|
26
|
+
const res = await fetch(`${serverUrl}/api/auth/me`, {
|
|
27
|
+
headers: { 'Authorization': `Bearer ${token}` },
|
|
28
|
+
signal: AbortSignal.timeout(5000),
|
|
29
|
+
});
|
|
30
|
+
if (res.ok) {
|
|
31
|
+
const data = await res.json();
|
|
32
|
+
const tokenCache = {
|
|
33
|
+
token,
|
|
34
|
+
userId: data.user.id,
|
|
35
|
+
email: data.user.email,
|
|
36
|
+
plan: data.user.plan,
|
|
37
|
+
expiresAt: Date.now() + 6 * 86400000,
|
|
38
|
+
};
|
|
39
|
+
_cache = tokenCache;
|
|
40
|
+
await fs.writeFile(cacheFile, JSON.stringify(tokenCache));
|
|
41
|
+
return tokenCache;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
catch { }
|
|
20
46
|
try {
|
|
21
47
|
const res = await fetch(`${serverUrl}/api/auth/login`, {
|
|
22
48
|
method: 'POST',
|
package/dist/index.js
CHANGED
|
@@ -15,7 +15,7 @@ import { SyncClient } from './sync-client';
|
|
|
15
15
|
import { homedir } from 'os';
|
|
16
16
|
const CONFIG = {
|
|
17
17
|
LLM_BASE_URL: 'http://127.0.0.1:18789/v1',
|
|
18
|
-
CLOUD_URL: '
|
|
18
|
+
CLOUD_URL: 'https://yulailai.com',
|
|
19
19
|
LLM_TIMEOUT_MS: 10000,
|
|
20
20
|
SKILL_COUNT_CACHE_TTL_MS: 30000,
|
|
21
21
|
CURRENT_VERSION: '3.0.0',
|