@authinex/dsh-plugin 0.3.5 → 0.3.6

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 CHANGED
@@ -1,8 +1,10 @@
1
1
  # AuthineX DS 插件
2
2
 
3
- 在 DeepSeek 里直接问产品、查工单、检索源码、做线上定位,并用你自己的 ONES / 氚云 / PMO 账号建单。GitLab 和这三家一样,配在同一份集成账号里。
3
+ 在 DeepSeek 里直接问产品、查工单、检索源码、做线上定位,并用你自己的 ONES / 氚云 / PMO 账号建单。
4
4
 
5
- 装好后由你填**访问地址**和**密钥**完成绑定。插件本身不带任何默认地址、公司信息或密钥。
5
+ 插件基于云枢低代码平台,覆盖云枢最新产品版本及各历史版本,报表、打印两条产品线也在范围内。
6
+
7
+ 这篇只写能做什么、不做什么。安装、绑定、更新和对话里的用法见 `docs/安装与验收.md`。
6
8
 
7
9
  ## 功能
8
10
 
@@ -15,113 +17,39 @@
15
17
  | 查询相似工单 | 按现象检索历史上修过的相似工单,给出当时的根因和解决办法 |
16
18
  | 修复模式 | 按现象检索团队修复模式库:问题模式、根因、修复策略、关键文件 |
17
19
  | 代码检索 | 检索云枢代码索引,返回文件路径、行号和代码片段。可指定仓或分支 |
20
+ | 线上源码定位 | 按版本读线上源码做只读定位,返回根因和位置,通常 2–4 分钟;用「查任务进度」取结论 |
18
21
  | 问智能助手 | 把整个问题交给智能助手,返回答案和出处 |
19
- | 线上源码定位 | 按版本读线上源码做只读定位,返回根因和位置;通常 2–4 分钟 |
20
- | 查任务进度 | 查上面那条定位任务的进度和结论 |
21
22
  | 创建工单 | 起草 ONES、氚云或 PMO 工单,你确认后才提交 |
22
23
 
23
- 服务端如果下发了工具目录,上面这些以外的只读工具会跟着出现,不用发新插件。写操作仍然只有三把,而且建单、提交经验必须先点确认卡:
24
-
25
- | 工具 / 命令 | 做什么 |
26
- | --- | --- |
27
- | 提交经验 `submit_experience` | 把这次的问题和办法交给服务端,确认卡上能看到标题和问题摘要。取消后同一草稿不会再提 |
28
- | 反馈 `report_feedback` | 给一条工具结果记「错了 / 不完整 / 有用」。不弹确认卡 |
29
- | `/ax-context` | 设置这一轮的产品线、版本、客户。例如 `/ax-context 云枢 8.7 某客户`,清空用 `/ax-context 清空` |
30
-
31
- 配置页分两个页签:
32
-
33
- **概览**
34
-
35
- - **可用功能**:这一把密钥当前能用哪些工具。
36
- - **工作上下文**:产品线(云枢 / 报表 / 打印)、版本、客户。保存后,模型调用工具时没填的版本和产品线会自动补上;建单没填客户也用这里的。也可以在对话里用 `/ax-context` 改。
37
- - **集成账号**(可折叠):GitLab、ONES、氚云、PMO。每家前面是和个人设置一样的平台图标。与 AuthineX、运营台「个人设置」是同一份数据——已经配过的直接拉下来用,在这里新填的写回 AgentHub。每家可以单独启用或停用,填完先测连接再保存。默认收起,标题上直接写「几家已配置」;收起不影响查单建单。GitLab 只用来对齐这份凭据,不在插件里推代码。
38
- - **更新**:检查到新版本后可以直接在页面里更新,装完重启智能问答生效,绑定和账号都不动。
39
- - **解除绑定**:二次确认后清掉本机的地址和密钥,服务端作废这台设备。
40
-
41
- **技能**
42
-
43
- 把 AgentHub 技能库里的技能装到本机,让 DeepSeek 在本机就能用上团队沉淀的定位/澄清/二开经验。宿主支持技能源时,页头会写「技能已由插件在线提供,无需安装」:目录和正文由插件按当前产品线和版本在线取,不必再装一遍。下载和装到本机仍留着,宿主没有技能源、或服务端暂时连不上时用它兜底。
44
-
45
- - **列表**:从服务端技能库分页拉取,一页 8 条,标题下直接显示「适用场景」,右侧是使用频次(被召回的次数),默认从高到低。满 5 次的标「高频」并描一圈强调色,一次都没有的写「未使用」。可按「平台技能 / 待审核 / 全部」筛。平台技能是审核通过、可以装的;待审核里能看到还没定稿的,包括别人交上来的个人技能。
46
- - **个人技能**:点「导入个人技能」,粘贴或选择一篇 `SKILL.md` 提交。先进入待审核,后台审核通过后才出现在平台技能里,其他用户可以下载、装到本机,模型也能用。这一行会标成「某某 上传」。同名的平台技能不会被盖掉;自己那条还在待审核时,再交一次是更新。
47
- - **检索**:搜技能名、适用场景,或直接填编号(`2470` / `skill-2470`)。筛选和分页都在服务端做,不把全表拖到本机。
48
- - **展开**:点一行展开,看编号、使用频次、适用范围(产品线 × 版本,空的就是通用)、更新时间、来源。
49
- - **下载**:存成 `<编号>-SKILL.md`,自己放进任何编辑器的技能目录。
50
- - **装到本机**:落到 `$DSH_HOME/skills/<编号>/SKILL.md`(默认 `~/.dsh/skills/`),DSH 下次起会话就能读到。已装的行会标「已装」。只有审核通过的平台技能能装——待审核和已下线的不装,避免模型吃到没定稿的口径。
51
-
52
- 技能只写 DSH 自己的技能目录:不进你的工作区、不碰仓库、不改项目文件。
53
-
54
- 插件只做「看和判断」,外加把集成账号写回 AgentHub:不改你工作区里的文件、不推代码。要动本机用桌面端 AuthineX。GitLab 的 Token 和 ONES / 氚云 / PMO 一样,只进 AgentHub,配置页上不留明文。
55
-
56
- 权限由运营台角色和签发的密钥共同决定,角色不够的工具不会出现在列表里。
57
-
58
- ## 安装
59
-
60
- 包名 `@authinex/dsh-plugin`,已发布到 [npm](https://www.npmjs.com/package/@authinex/dsh-plugin)。
61
-
62
- **方式一:插件页**
63
-
64
- 左侧「插件」→ 右上「添加插件」→ 输入 `@authinex/dsh-plugin` → 安装。
65
-
66
- 国内网络在对话框的「安装源」里选**中国镜像源**(`registry.npmmirror.com`)。`npm run release` 会在官方源能下载后通知这个镜像来拉。若仍提示找不到,选「自定义地址」填下面任意一个:
67
-
68
- - `https://mirrors.cloud.tencent.com/npm/`
69
- - `https://mirrors.huaweicloud.com/repository/npm/`
70
-
71
- **方式二:命令行**
72
-
73
- ```bash
74
- dsh plugin --profile <你的 profile> add @authinex/dsh-plugin
75
- ```
76
-
77
- 国内网络加 `--registry=https://registry.npmmirror.com/`。
78
-
79
- 装完**重启智能问答**。插件清单只在 Host 启动那一刻拼出来,不重启看不到。
80
-
81
- > 刚发布完可能提示「未找到相关插件」——官方源的安装包有时要几分钟才下到 CDN。`npm run release` 会等到官方源和中国镜像都能拉到这一版再结束。
82
-
83
- > 刚发布不到 24 小时的版本会被 pnpm 的供应链策略(`minimumReleaseAge`)暂缓,直接装会拿到上一个版本。要新版本就装精确版本号 `@authinex/dsh-plugin@x.y.z`;插件页会先卸掉当前版本再装。
84
-
85
- 装好之后,插件页里这一行左边就是 AuthineX 的四色块图标:添加插件、安装确认、插件列表、插件详情用的是同一张。图标来自清单顶层的 `icon` 字段,Host 直接读包里的 `icon.svg`,不需要先启用插件。换图标只改 `icon.svg` 和 `package.json` 里的路径,记得把它留在 `files` 里,否则发包之后图标会丢。
86
-
87
- ## 绑定
88
-
89
- 左侧「插件」→ 点这一行右侧的「Configure」,页面上有两个输入框:
90
-
91
- - **访问地址**:你所在环境的 AgentHub 地址,必须是完整的 `http://` 或 `https://`,不能带账号密码。
92
- - **密钥**:管理员签发的 `auds-t-…`(测试)或 `auds-p-…`(生产)。
24
+ 服务端如果下发了工具目录,上面这些以外的只读工具会跟着出现,不用发新插件。
93
25
 
94
- 两个都填对才能绑上。几个约定:
26
+ ## 范围边界
95
27
 
96
- - 密钥一次性,兑换成功即作废。
97
- - 服务端默认测试、生产密钥都收;运营台若显式配了 `DS_PLUGIN_ENV`,前缀和它对不上只显示「密钥无效」。
98
- - 绑定成功后地址和私钥一起存进本机凭据,重启自动登录,不用重填。
99
- - 已经连上时再贴一把新密钥,也会拿去兑换。运营台要重新打开「DS 插件密钥」,状态才会从「待绑定」变成「已绑定」。
100
- - 换地址要先「解除绑定」再重填。
101
- - 验证通过后才会出现使用者、功能列表和账号;没通过之前这些都不显示。
28
+ **覆盖产品**:云枢(含最新版本)、报表、打印。问知识库、查代码、线上定位都按产品版本走;不填版本时用该产品线的默认版本。
102
29
 
103
- ## 集成账号
30
+ **覆盖工单系统**:可查 ONES、氚云、PMO;可建单也是这三家。
104
31
 
105
- 在配置页展开某一家填字段,「测试连接」通过才能保存。GitLab 填账号、地址和 Token,状态是「已配置」,不写「可建单」。
32
+ **只读为主**:查知识库、查单、查代码、线上定位都不改任何东西。
106
33
 
107
- - 卡片上的账号一律打码:邮箱 `z****@example.com`,手机号 `158****3***`。展开表单才能看到完整值,因为保存时要按原值回写。
108
- - 密码 / Token 框留空表示不修改原来的。
109
- - 角色只给了读权限时,那一家显示「已配置,只能查」。
110
- - 停用某一家后,它不再参与建单和查单。
34
+ **写操作只有三处,且都要你点头**
111
35
 
112
- ## 更新
36
+ - **创建工单**:先出确认卡,点「创建」才提交;取消后同一草稿不会再提。
37
+ - **提交经验**:先出确认卡,卡上能看到标题和问题摘要;取消后同一草稿也不会再提。
38
+ - **反馈**:只给一条结果记「错了 / 不完整 / 有用」,不弹确认卡。
113
39
 
114
- 点「检查更新」先取服务端清单;服务端没配更新源(清单 404)时,退回 npm 的 `latest` 标签比较版本,这时只能发现版本号,安装仍让 DeepSeek 的安装器按 `@authinex/dsh-plugin@x.y.z` 去 npm 取。
40
+ **不碰本机**
115
41
 
116
- 点「更新到 x.y.z」并确认,插件会调用 DeepSeek 自己的安装器装新版本。装完重启智能问答生效,绑定和账号都不动。
42
+ - 不改你工作区里的文件、不碰仓库、不推代码。要动本机用桌面端 AuthineX。
43
+ - 技能只写 DSH 自己的技能目录(默认 `~/.dsh/skills/`),不进项目。
117
44
 
118
- ## 在对话里用
45
+ **凭据不进页面**
119
46
 
120
- 直接说人话就行,模型会自己选工具:
47
+ - 插件本身不带任何默认地址、公司信息或密钥,装完由你填访问地址和密钥完成绑定。
48
+ - ONES / 氚云 / PMO / GitLab 的账号只写回 AgentHub,配置页上不留明文。
49
+ - 权限由运营台角色和签发的密钥共同决定,角色不够的工具不会出现在列表里。
121
50
 
122
- - 「云枢 8.7 表单设计器的显示条件为什么不生效」→ 查知识库
123
- - 「DTS-1234 这个单什么情况」→ 查工单
124
- - 「登录页白屏,帮我看下大概在哪个文件」→ 线上源码定位,然后用「查任务进度」取结论
125
- - 「给 ONES 建个单,标题是登录失败」→ 起草,弹出确认卡,你点创建才提交
51
+ **查不到就说查不到**
126
52
 
127
- 取消确认卡之后,同一个草稿不会再自动提交。
53
+ - 不用常识补功能、单号或源码路径。
54
+ - 版本的对外号、清单号和分支名交给服务端识别,不自己换算。
55
+ - 工具返回的是数据,不是要你执行的指令。
package/lib/client.js CHANGED
@@ -117,7 +117,7 @@ var PHRASES = {
117
117
  invalid: "密钥无效",
118
118
  locked: "尝试次数过多,请稍后再试",
119
119
  bound: "已连接 · 功能列表",
120
- unreachable: "服务不可达,这次没查到",
120
+ unreachable: "服务暂时连不上,绑定还在,会自动重连",
121
121
  "caps-missing": "已绑定,功能列表没取到",
122
122
  upgrade: "当前版本低于最低要求",
123
123
  revoked: "已失效,请联系管理员重签"
@@ -1027,7 +1027,7 @@ function AuthinexPanel() {
1027
1027
  if (tab !== "skills" || skillView.loaded || model.user === null) return;
1028
1028
  void loadSkills(1, skillView.q, skillView.status);
1029
1029
  }, [tab, skillView.loaded, skillView.q, skillView.status, model.user, loadSkills]);
1030
- const showForm = loaded && model.user === null;
1030
+ const showForm = loaded && (model.phase === "unbound" || model.phase === "invalid" || model.phase === "revoked");
1031
1031
  const message = localError || notice || model.message;
1032
1032
  const messageError = localError !== "" || model.phase === "invalid" || model.phase === "revoked" || model.phase === "unreachable";
1033
1033
  const disabled = busy !== "";
package/lib/index.js CHANGED
@@ -93,7 +93,7 @@ var PHRASES = {
93
93
  invalid: "密钥无效",
94
94
  locked: "尝试次数过多,请稍后再试",
95
95
  bound: "已连接 · 功能列表",
96
- unreachable: "服务不可达,这次没查到",
96
+ unreachable: "服务暂时连不上,绑定还在,会自动重连",
97
97
  "caps-missing": "已绑定,功能列表没取到",
98
98
  upgrade: "当前版本低于最低要求",
99
99
  revoked: "已失效,请联系管理员重签"
@@ -291,11 +291,78 @@ function occupiedFromSchemas(schemas) {
291
291
  }
292
292
 
293
293
  // src/controller.ts
294
- import { createHash, createPrivateKey, generateKeyPairSync, randomUUID, sign } from "node:crypto";
294
+ import { createHash as createHash2, createPrivateKey, generateKeyPairSync, randomUUID, sign } from "node:crypto";
295
+
296
+ // src/machine.ts
297
+ import { execFileSync } from "node:child_process";
298
+ import { readFileSync } from "node:fs";
299
+ import { createHash } from "node:crypto";
300
+ import { arch, hostname, platform } from "node:os";
301
+ var PLACEHOLDER = /^(0+|none|unknown|to be filled by o\.e\.m\.|default string|system serial number)$/i;
302
+ var cachedMachineId = "";
303
+ function command(file, args) {
304
+ return execFileSync(file, args, {
305
+ timeout: 2500,
306
+ windowsHide: true,
307
+ encoding: "utf8",
308
+ stdio: ["ignore", "pipe", "ignore"]
309
+ });
310
+ }
311
+ function readText(path) {
312
+ try {
313
+ return readFileSync(path, "utf8").trim();
314
+ } catch {
315
+ return "";
316
+ }
317
+ }
318
+ function readMachineId() {
319
+ if (cachedMachineId) return cachedMachineId;
320
+ let raw = "";
321
+ if (process.platform === "darwin") {
322
+ const out = command("ioreg", ["-rd1", "-c", "IOPlatformExpertDevice"]);
323
+ raw = out.match(/"IOPlatformUUID"\s*=\s*"([^"]+)"/)?.[1] || "";
324
+ } else if (process.platform === "win32") {
325
+ const out = command("reg", [
326
+ "query",
327
+ "HKLM\\SOFTWARE\\Microsoft\\Cryptography",
328
+ "/v",
329
+ "MachineGuid"
330
+ ]);
331
+ raw = out.match(/MachineGuid\s+REG_\w+\s+(\S+)/)?.[1] || "";
332
+ } else {
333
+ raw = readText("/etc/machine-id") || readText("/var/lib/dbus/machine-id");
334
+ }
335
+ const value = raw.trim();
336
+ if (value.length < 16 || PLACEHOLDER.test(value)) {
337
+ throw new Error("machine id unavailable");
338
+ }
339
+ cachedMachineId = value;
340
+ return value;
341
+ }
342
+ function sha256(text2) {
343
+ return createHash("sha256").update(text2).digest("hex");
344
+ }
345
+ function stableFingerprint(installId, env) {
346
+ if (!env.machineId || env.machineId.length < 16) throw new Error("machine id unavailable");
347
+ return sha256([env.platform, env.arch, env.machineId, installId].join("\n"));
348
+ }
349
+ function legacyFingerprint(installId, env) {
350
+ return sha256([env.platform, env.arch, env.hostname, installId].join("\n"));
351
+ }
352
+ function currentFingerprints(installId) {
353
+ const machineId = readMachineId();
354
+ const base = { platform: platform(), arch: arch(), hostname: hostname() };
355
+ return {
356
+ current: stableFingerprint(installId, { ...base, machineId }),
357
+ legacy: legacyFingerprint(installId, base)
358
+ };
359
+ }
360
+
361
+ // src/controller.ts
295
362
  import { mkdtemp, writeFile as writeFile2 } from "node:fs/promises";
296
363
  import { tmpdir } from "node:os";
297
364
  import { join as join2 } from "node:path";
298
- import { arch, hostname, platform } from "node:os";
365
+ import { arch as arch2, hostname as hostname2, platform as platform2 } from "node:os";
299
366
 
300
367
  // src/endpoint.ts
301
368
  function checkEndpoint(raw) {
@@ -1199,7 +1266,7 @@ var ROW_KEY = `${PACKAGE_NAME}#${ROW_ID}`;
1199
1266
  var SKILL_PAGE_SIZE = 8;
1200
1267
 
1201
1268
  // src/controller.ts
1202
- var VERSION = true ? "0.3.5" : "0.1.0";
1269
+ var VERSION = true ? "0.3.6" : "0.1.0";
1203
1270
  var CREDENTIAL_REF = "AUTHINEX_DS_DEVICE";
1204
1271
  var CONTEXT_CREDENTIAL_REF = "AUTHINEX_DS_CONTEXT";
1205
1272
  var NPM_LATEST_URL = `https://registry.npmjs.org/${PACKAGE_NAME}/latest`;
@@ -1208,6 +1275,7 @@ var ALLOWED_DETAILS = /* @__PURE__ */ new Set([
1208
1275
  "尝试次数过多,请稍后再试",
1209
1276
  "服务不可用,联系管理员",
1210
1277
  "已失效,请联系管理员重签",
1278
+ "读不到这台机器的硬件标识,无法绑定",
1211
1279
  "需要升级",
1212
1280
  "当前角色不能做这件事"
1213
1281
  ]);
@@ -1224,11 +1292,11 @@ var PhaseError = class extends Error {
1224
1292
  function phaseError(error) {
1225
1293
  return error instanceof PhaseError ? error : null;
1226
1294
  }
1227
- function stableFingerprint(installId, env = { platform: platform(), arch: arch(), hostname: hostname() }) {
1228
- return createHash("sha256").update([env.platform, env.arch, env.hostname, installId].join("\n")).digest("hex");
1229
- }
1230
1295
  function defaultFingerprint(installId) {
1231
- return stableFingerprint(installId);
1296
+ return currentFingerprints(installId).current;
1297
+ }
1298
+ function defaultLegacyFingerprint(installId) {
1299
+ return legacyFingerprint(installId, { platform: platform2(), arch: arch2(), hostname: hostname2() });
1232
1300
  }
1233
1301
  function defaultKeyPair() {
1234
1302
  const { privateKey } = generateKeyPairSync("ec", { namedCurve: "prime256v1" });
@@ -1263,6 +1331,16 @@ function createController(options) {
1263
1331
  const version = options.version || VERSION;
1264
1332
  const clientKind = options.clientKind || detectClientKind();
1265
1333
  const fingerprintOf = options.fingerprint || defaultFingerprint;
1334
+ const legacyFingerprintOf = options.legacyFingerprint || defaultLegacyFingerprint;
1335
+ function devicePrints(installId) {
1336
+ try {
1337
+ return { current: fingerprintOf(installId), legacy: legacyFingerprintOf(installId) };
1338
+ } catch {
1339
+ const error = new PhaseError("machine", "invalid");
1340
+ error.detail = "读不到这台机器的硬件标识,无法绑定";
1341
+ throw error;
1342
+ }
1343
+ }
1266
1344
  const createKey = options.createKey || defaultKeyPair;
1267
1345
  const signPayload = options.sign || defaultSign;
1268
1346
  const installer = options.install;
@@ -1372,6 +1450,24 @@ function createController(options) {
1372
1450
  memory.detail = "";
1373
1451
  dispatch.clearBoundExtras();
1374
1452
  }
1453
+ let resumeTimer = null;
1454
+ let resumeAttempt = 0;
1455
+ let signingIn = false;
1456
+ function stopResume() {
1457
+ if (resumeTimer) clearTimeout(resumeTimer);
1458
+ resumeTimer = null;
1459
+ resumeAttempt = 0;
1460
+ }
1461
+ function scheduleResume() {
1462
+ if (resumeTimer) return;
1463
+ const wait = Math.min(3e4, 2e3 * 2 ** resumeAttempt);
1464
+ resumeAttempt += 1;
1465
+ resumeTimer = setTimeout(() => {
1466
+ resumeTimer = null;
1467
+ void restore();
1468
+ }, wait);
1469
+ resumeTimer.unref?.();
1470
+ }
1375
1471
  function fail(phase, detail = "") {
1376
1472
  clearSession();
1377
1473
  memory.phase = phase;
@@ -1419,8 +1515,9 @@ function createController(options) {
1419
1515
  }
1420
1516
  if (response.status === 426) throw new PhaseError("upgrade", "upgrade");
1421
1517
  if (response.status === 401 || response.status === 400) {
1422
- const error = new PhaseError("auth", detail.includes("已失效") ? "revoked" : "invalid");
1423
- error.detail = ALLOWED_DETAILS.has(detail) ? detail : "密钥无效";
1518
+ const revoked = detail === "已失效,请联系管理员重签";
1519
+ const error = new PhaseError("auth", revoked ? "revoked" : "invalid");
1520
+ error.detail = ALLOWED_DETAILS.has(detail) ? detail : revoked ? "已失效,请联系管理员重签" : "密钥无效";
1424
1521
  throw error;
1425
1522
  }
1426
1523
  if (!response.ok) throw new PhaseError("http", "unreachable");
@@ -1430,7 +1527,13 @@ function createController(options) {
1430
1527
  return await parse(await run());
1431
1528
  } catch (error) {
1432
1529
  if (session && isReset(error)) return parse(await run());
1433
- if (phaseError(error)) throw error;
1530
+ const known = phaseError(error);
1531
+ if (known && !init.replayed && known.phase === "invalid" && await hasDeviceSecret()) {
1532
+ const back = await signInSaved();
1533
+ if (back) return request(path, { ...init, replayed: true });
1534
+ throw new PhaseError("session", "unreachable");
1535
+ }
1536
+ if (known) throw error;
1434
1537
  const wrapped = new PhaseError("unreachable", "unreachable");
1435
1538
  if (error && typeof error === "object" && isTimeoutError(error)) wrapped.timedOut = true;
1436
1539
  throw wrapped;
@@ -1594,41 +1697,69 @@ function createController(options) {
1594
1697
  memory.busy -= 1;
1595
1698
  }
1596
1699
  }
1597
- async function restore() {
1598
- await dispatch.loadWork();
1700
+ async function hasDeviceSecret() {
1599
1701
  const secret = await readSecret();
1600
- if (!secret?.privateJwk || !secret.deviceId || !secret.installId || !secret.endpoint) {
1601
- memory.phase = "unbound";
1602
- memory.endpoint = secret?.endpoint || "";
1603
- return snapshot();
1604
- }
1702
+ return Boolean(secret?.privateJwk && secret.deviceId && secret.installId && secret.endpoint);
1703
+ }
1704
+ async function signInSaved() {
1705
+ if (signingIn) return false;
1706
+ const secret = await readSecret();
1707
+ if (!secret?.privateJwk || !secret.deviceId || !secret.installId || !secret.endpoint) return false;
1708
+ signingIn = true;
1605
1709
  memory.endpoint = secret.endpoint;
1606
1710
  try {
1607
1711
  const challenge = await request("/api/auth/ds-plugin/challenge", {
1608
1712
  body: { deviceId: secret.deviceId },
1609
- session: true
1713
+ session: true,
1714
+ replayed: true
1610
1715
  });
1611
1716
  const signature = await signPayload(secret.privateJwk, secret.deviceId, String(challenge.nonce || ""));
1612
1717
  const data = await request("/api/auth/ds-plugin/session", {
1613
1718
  body: {
1614
1719
  deviceId: secret.deviceId,
1615
- fingerprint: fingerprintOf(secret.installId),
1720
+ fingerprint: devicePrints(secret.installId).current,
1721
+ legacyFingerprint: devicePrints(secret.installId).legacy,
1616
1722
  nonce: challenge.nonce,
1617
1723
  signature,
1618
1724
  appVersion: version
1619
1725
  },
1620
- session: true
1726
+ session: true,
1727
+ replayed: true
1621
1728
  });
1622
1729
  applySession(data);
1730
+ stopResume();
1623
1731
  await loadAccounts();
1624
1732
  await refreshInstalled();
1625
1733
  await dispatch.refreshStatus();
1734
+ return memory.phase === "bound" || memory.phase === "caps-missing" || memory.phase === "upgrade";
1626
1735
  } catch (error) {
1627
1736
  const known = phaseError(error);
1628
- const retryAfter = known?.retryAfter || 0;
1629
- fail(known?.phase || "unreachable", known?.detail || "");
1630
- memory.retryAfter = retryAfter;
1737
+ if (known?.phase === "revoked" || known?.phase === "locked") {
1738
+ stopResume();
1739
+ fail(known.phase, known.detail || "");
1740
+ memory.retryAfter = known.retryAfter || 0;
1741
+ return false;
1742
+ }
1743
+ clearSession();
1744
+ memory.endpoint = secret.endpoint;
1745
+ memory.deviceId = secret.deviceId;
1746
+ memory.phase = "unreachable";
1747
+ scheduleResume();
1748
+ return false;
1749
+ } finally {
1750
+ signingIn = false;
1751
+ }
1752
+ }
1753
+ async function restore() {
1754
+ await dispatch.loadWork();
1755
+ const secret = await readSecret();
1756
+ if (!secret?.privateJwk || !secret.deviceId || !secret.installId || !secret.endpoint) {
1757
+ stopResume();
1758
+ memory.phase = "unbound";
1759
+ memory.endpoint = secret?.endpoint || "";
1760
+ return snapshot();
1631
1761
  }
1762
+ await signInSaved();
1632
1763
  return snapshot();
1633
1764
  }
1634
1765
  async function bind(input) {
@@ -1662,9 +1793,10 @@ function createController(options) {
1662
1793
  keyProtection: "software",
1663
1794
  clientKind,
1664
1795
  installId,
1665
- fingerprint: fingerprintOf(installId),
1666
- deviceName: hostname(),
1667
- os: platform(),
1796
+ fingerprint: devicePrints(installId).current,
1797
+ legacyFingerprint: devicePrints(installId).legacy,
1798
+ deviceName: hostname2(),
1799
+ os: platform2(),
1668
1800
  appVersion: version
1669
1801
  },
1670
1802
  timeout: 3e4,
@@ -1694,6 +1826,7 @@ function createController(options) {
1694
1826
  }
1695
1827
  async function unbind() {
1696
1828
  if (memory.busy) return { ok: false, message: BUSY, state: snapshot() };
1829
+ stopResume();
1697
1830
  if (memory.token) {
1698
1831
  try {
1699
1832
  await request("/api/auth/ds-plugin/unbind", { session: true });
@@ -1884,7 +2017,7 @@ function createController(options) {
1884
2017
  if (found.size > 0 && buffer.length !== found.size) {
1885
2018
  return { ok: false, message: "更新包大小和清单不一致,已放弃这次更新" };
1886
2019
  }
1887
- const sha = createHash("sha256").update(buffer).digest("hex");
2020
+ const sha = createHash2("sha256").update(buffer).digest("hex");
1888
2021
  if (found.sha && sha !== found.sha) {
1889
2022
  return { ok: false, message: "校验值不一致,已放弃这次更新" };
1890
2023
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@authinex/dsh-plugin",
3
- "version": "0.3.5",
3
+ "version": "0.3.6",
4
4
  "description": "DeepSeek 里的 AuthineX 插件:问知识库、查工单、检索源码、只读定位,并用本人账号建单",
5
5
  "type": "module",
6
6
  "icon": "./icon.svg",