@honor-claw/yoyo 2026.6.9-alpha.13 → 2026.6.9-alpha.14
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.
|
@@ -1,49 +1,51 @@
|
|
|
1
1
|
import { clawLogger as e } from "../../utils/claw-logger.mjs";
|
|
2
2
|
import { getPersistedIdentity as t, updatePersistedIdentity as n } from "../../modules/configs/identity-persist.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { loadConfig as r, saveConfig as i } from "../../modules/configs/config-store.mjs";
|
|
4
|
+
import { clearUserConfig as a, getUserConfig as o } from "../../modules/configs/plugin.mjs";
|
|
5
|
+
import { patchYoyoChannelConfig as s, setAllYoyoChannelAccountsEnabled as c, setYoyoChannelAccountEnabled as l } from "../../modules/configs/channel.mjs";
|
|
4
6
|
import "../../modules/configs/index.mjs";
|
|
5
|
-
import { parseTokenExpireMs as
|
|
6
|
-
import { HonorAccount as
|
|
7
|
-
import { createClawCloudClient as
|
|
8
|
-
import { loadDeviceInfo as
|
|
7
|
+
import { parseTokenExpireMs as u } from "./token-expiry.mjs";
|
|
8
|
+
import { HonorAccount as d } from "./impl.mjs";
|
|
9
|
+
import { createClawCloudClient as f } from "../../apis/claw-cloud.mjs";
|
|
10
|
+
import { loadDeviceInfo as p } from "../../modules/device/device-info.mjs";
|
|
9
11
|
import "../../modules/device/index.mjs";
|
|
10
12
|
//#region src/honor-auth/vault/legacy-migration.ts
|
|
11
|
-
var
|
|
12
|
-
async function
|
|
13
|
+
var m = e("auth");
|
|
14
|
+
async function h() {
|
|
13
15
|
try {
|
|
14
|
-
let e =
|
|
15
|
-
if (!
|
|
16
|
-
|
|
16
|
+
let e = o(), h = e?.token, g = e?.userId, _ = (await t())?.authorizationCache, v = _?.jwtToken, y = _?.receivedAtMs, b = _?.expireMs, x = v ?? h;
|
|
17
|
+
if (!x) {
|
|
18
|
+
m.debug("no legacy token to migrate");
|
|
17
19
|
return;
|
|
18
20
|
}
|
|
19
|
-
let
|
|
20
|
-
if (!
|
|
21
|
-
let e = await
|
|
22
|
-
|
|
23
|
-
hasUserId: !!
|
|
24
|
-
hasExpire: !!
|
|
21
|
+
let S = g, C = x, w = u(b), T = y;
|
|
22
|
+
if (!S || !w) try {
|
|
23
|
+
let e = await p(), t = await f().exchangeToken(e, { token: x });
|
|
24
|
+
S ||= t.userId, w || (C = t.jwtToken ?? C, w = t.expire ?? w, T = Date.now()), m.info("exchanged legacy token for missing fields", {
|
|
25
|
+
hasUserId: !!S,
|
|
26
|
+
hasExpire: !!w
|
|
25
27
|
});
|
|
26
28
|
} catch (e) {
|
|
27
|
-
|
|
29
|
+
m.warn("failed to exchange legacy token for missing fields", e);
|
|
28
30
|
}
|
|
29
|
-
if (!
|
|
30
|
-
|
|
31
|
+
if (!S) {
|
|
32
|
+
m.warn("legacy token missing userId and exchange failed, skip migration");
|
|
31
33
|
return;
|
|
32
34
|
}
|
|
33
|
-
let
|
|
34
|
-
accessToken:
|
|
35
|
-
expire:
|
|
36
|
-
grantedAt:
|
|
35
|
+
let E = u(w), D = {
|
|
36
|
+
accessToken: C,
|
|
37
|
+
expire: E,
|
|
38
|
+
grantedAt: T,
|
|
37
39
|
metadata: {
|
|
38
|
-
userInfo: { userId:
|
|
39
|
-
legacyReceivedAtMs:
|
|
40
|
-
legacyExpireMs:
|
|
40
|
+
userInfo: { userId: S },
|
|
41
|
+
legacyReceivedAtMs: y,
|
|
42
|
+
legacyExpireMs: b
|
|
41
43
|
}
|
|
42
44
|
};
|
|
43
|
-
await
|
|
45
|
+
await d.fromUser(S).save(D), m.info("migrated legacy token to vault", { accountKey: S }), (h || g) && await a(), _ && await n({ authorizationCache: void 0 }), await i(s(l(c(r(), !1), S, !0), { enabled: !0 })), m.info("enabled migrated legacy account in yoyo channel", { accountKey: S });
|
|
44
46
|
} catch (e) {
|
|
45
|
-
|
|
47
|
+
m.warn("legacy token migration failed", e);
|
|
46
48
|
}
|
|
47
49
|
}
|
|
48
50
|
//#endregion
|
|
49
|
-
export {
|
|
51
|
+
export { h as migrateLegacyHonorToken };
|