@inventec/dsh-copilot-auth 1.2.0 → 1.2.1
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/package.json +1 -1
- package/src/host.mjs +13 -3
package/package.json
CHANGED
package/src/host.mjs
CHANGED
|
@@ -99,9 +99,13 @@ async function syncAvailableModels(ctx) {
|
|
|
99
99
|
ids = available.filter((id) => served.has(id));
|
|
100
100
|
}
|
|
101
101
|
if (ids.length === 0) return;
|
|
102
|
+
// 真 CAS(与 boot 2a 同款,2026-09-28 审计补充):携带 expectedRevision 提交,
|
|
103
|
+
// 与用户在 Models 页的并发编辑互斥——冲突时 settings 抛 SETTINGS_CONFLICT,
|
|
104
|
+
// 由 sync() 的 catch 记入 syncError(失败不静默),不再有静默覆盖窗口。
|
|
105
|
+
const desc = ctx.settings?.describe?.()?.find?.((x) => x?.ns === "llm-pi-ai");
|
|
102
106
|
await ctx.settings.mutate("llm-pi-ai", [
|
|
103
107
|
{ op: "set", path: ["providers", "github-copilot", "models"], value: ids.map((id) => ({ id })) },
|
|
104
|
-
]);
|
|
108
|
+
], desc?.revision);
|
|
105
109
|
}
|
|
106
110
|
|
|
107
111
|
function sameOrigin(req) {
|
|
@@ -573,8 +577,14 @@ export function apply(ctx, opts = {}) {
|
|
|
573
577
|
handler: async (req, res) => {
|
|
574
578
|
if (!guard(req, res, "POST")) return;
|
|
575
579
|
// 幂等契约:deleteRecord 对不存在记录是 no-op 且正常 resolve,
|
|
576
|
-
// 真实删除与否由随后的 /status
|
|
577
|
-
|
|
580
|
+
// 真实删除与否由随后的 /status 反映。异常兜底与其余路由对齐
|
|
581
|
+
// (2026-09-28 审计:无 try/catch 的 reject 会造成连接悬挂/未处理拒绝)。
|
|
582
|
+
try {
|
|
583
|
+
await ctx.credentials.deleteRecord(CREDENTIAL_KEY);
|
|
584
|
+
} catch (err) {
|
|
585
|
+
json(res, 500, { ok: false, error: String(err?.message ?? err) });
|
|
586
|
+
return;
|
|
587
|
+
}
|
|
578
588
|
json(res, 200, { ok: true });
|
|
579
589
|
},
|
|
580
590
|
});
|