@authinex/dsh-plugin 0.1.3 → 0.1.4
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 +1 -0
- package/lib/client.js +44 -0
- package/lib/index.js +10 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -69,6 +69,7 @@ dsh plugin --profile <你的 profile> add @authinex/dsh-plugin
|
|
|
69
69
|
- 密钥一次性,兑换成功即作废。
|
|
70
70
|
- 测试密钥只能连测试环境,前缀和服务对不上只显示「密钥无效」。
|
|
71
71
|
- 绑定成功后地址和私钥一起存进本机凭据,重启自动登录,不用重填。
|
|
72
|
+
- 已经连上时再贴一把新密钥,也会拿去兑换。运营台要重新打开「DS 插件密钥」,状态才会从「待绑定」变成「已绑定」。
|
|
72
73
|
- 换地址要先「解除绑定」再重填。
|
|
73
74
|
- 验证通过后才会出现使用者、功能列表和账号;没通过之前这些都不显示。
|
|
74
75
|
|
package/lib/client.js
CHANGED
|
@@ -412,6 +412,26 @@ function AuthinexPanel() {
|
|
|
412
412
|
setNotice(String(body.message || ""));
|
|
413
413
|
});
|
|
414
414
|
};
|
|
415
|
+
const onRebind = () => {
|
|
416
|
+
const url = (model.endpoint || endpoint).trim();
|
|
417
|
+
const problem = checkEndpoint(url);
|
|
418
|
+
if (problem) {
|
|
419
|
+
setLocalError(problem);
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
if (!parseKey(key)) {
|
|
423
|
+
setLocalError("密钥格式不对,管理员发的密钥形如 auds-t-XXXX-XXXX-XXX");
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
void run("bind", async () => {
|
|
427
|
+
const body = await api("/authinex-ds/bind", { method: "POST", body: { endpoint: url, key } });
|
|
428
|
+
applyState(body);
|
|
429
|
+
setKey("");
|
|
430
|
+
const failed = body.phase === "invalid" || body.phase === "unreachable" || body.phase === "revoked" || body.phase === "locked";
|
|
431
|
+
setNotice(String(body.message || (failed ? "没有绑定" : "已绑定")));
|
|
432
|
+
setFeedback(failed ? "error" : "ok");
|
|
433
|
+
});
|
|
434
|
+
};
|
|
415
435
|
const onUnbind = () => {
|
|
416
436
|
setConfirmUnbind(false);
|
|
417
437
|
void run("unbind", async () => {
|
|
@@ -503,6 +523,7 @@ function AuthinexPanel() {
|
|
|
503
523
|
void run("update-apply", async () => {
|
|
504
524
|
const body = await api("/authinex-ds/update/apply", { method: "POST" });
|
|
505
525
|
setNotice(String(body.message || (body.ok ? "已更新" : "没有更新")));
|
|
526
|
+
setFeedback(body.ok ? "ok" : "error");
|
|
506
527
|
if (body.ok) setRestart(true);
|
|
507
528
|
});
|
|
508
529
|
};
|
|
@@ -701,6 +722,29 @@ function AuthinexPanel() {
|
|
|
701
722
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { size: "sm", variant: "primary", disabled, onClick: onApplyUpdate, children: "确认更新" })
|
|
702
723
|
] }) : null,
|
|
703
724
|
restart ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "axds-notice", children: "已装好,重启智能问答后新版本才生效。" }) : null,
|
|
725
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "axds-card", children: [
|
|
726
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: "axds-field", children: [
|
|
727
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "新密钥" }),
|
|
728
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
729
|
+
import_dsh_client_ui_primitives.Input,
|
|
730
|
+
{
|
|
731
|
+
className: "axds-input",
|
|
732
|
+
value: key,
|
|
733
|
+
placeholder: "auds-p-XXXX-XXXX-XXX",
|
|
734
|
+
autoComplete: "off",
|
|
735
|
+
spellCheck: false,
|
|
736
|
+
onChange: (event) => {
|
|
737
|
+
setKey(event.target.value);
|
|
738
|
+
setLocalError("");
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
)
|
|
742
|
+
] }),
|
|
743
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "axds-actions", children: [
|
|
744
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "axds-muted", children: "贴一把新密钥会重新兑换,运营台才会变成已绑定" }),
|
|
745
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { size: "sm", variant: "primary", disabled: disabled || key.trim() === "", onClick: onRebind, children: "绑定这把密钥" })
|
|
746
|
+
] })
|
|
747
|
+
] }),
|
|
704
748
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "axds-row", children: [
|
|
705
749
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { size: "sm", disabled, onClick: onCheckUpdate, children: busy === "update" ? "检查中" : "检查更新" }),
|
|
706
750
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { size: "sm", variant: "outline", disabled, onClick: () => {
|
package/lib/index.js
CHANGED
|
@@ -215,7 +215,7 @@ var ROW_ID = "authinex-ds-plugin";
|
|
|
215
215
|
var ROW_KEY = `${PACKAGE_NAME}#${ROW_ID}`;
|
|
216
216
|
|
|
217
217
|
// src/controller.ts
|
|
218
|
-
var VERSION = true ? "0.1.
|
|
218
|
+
var VERSION = true ? "0.1.4" : "0.1.0";
|
|
219
219
|
var CREDENTIAL_REF = "AUTHINEX_DS_DEVICE";
|
|
220
220
|
var NPM_LATEST_URL = `https://registry.npmjs.org/${PACKAGE_NAME}/latest`;
|
|
221
221
|
var ALLOWED_DETAILS = /* @__PURE__ */ new Set([
|
|
@@ -500,17 +500,8 @@ function createController(options) {
|
|
|
500
500
|
if (!parsed) {
|
|
501
501
|
return { ok: false, message: PHRASES.invalid, state: fail("invalid") };
|
|
502
502
|
}
|
|
503
|
-
if (memory.token && memory.phase === "bound" && memory.endpoint === endpoint) {
|
|
504
|
-
return { ok: true, state: snapshot() };
|
|
505
|
-
}
|
|
506
503
|
memory.endpoint = endpoint;
|
|
507
504
|
const existing = await readSecret();
|
|
508
|
-
const samePlace = Boolean(existing?.endpoint) && existing?.endpoint === endpoint;
|
|
509
|
-
if (samePlace && existing?.privateJwk && existing.deviceId) {
|
|
510
|
-
const restored = await restore();
|
|
511
|
-
if (memory.token) return { ok: true, state: restored };
|
|
512
|
-
memory.endpoint = endpoint;
|
|
513
|
-
}
|
|
514
505
|
memory.phase = "binding";
|
|
515
506
|
memory.detail = "";
|
|
516
507
|
const installId = existing?.installId || randomUUID();
|
|
@@ -977,7 +968,15 @@ function apply(ctx) {
|
|
|
977
968
|
install: async (spec) => {
|
|
978
969
|
const service = manager();
|
|
979
970
|
if (!service) throw new Error("没有可用的插件管理器");
|
|
980
|
-
|
|
971
|
+
let result;
|
|
972
|
+
try {
|
|
973
|
+
result = await service.installBundle(spec, { enabled: true });
|
|
974
|
+
} catch (error) {
|
|
975
|
+
if (/already-installed/.test(String(error?.message || error))) {
|
|
976
|
+
throw new Error("这台机器上已经装了这个插件;请在插件页卸载,再安装新版本");
|
|
977
|
+
}
|
|
978
|
+
throw error;
|
|
979
|
+
}
|
|
981
980
|
if (result?.application === "failed") {
|
|
982
981
|
throw new Error(result.error?.code || result.packageResult?.kind || "安装失败");
|
|
983
982
|
}
|