@sunshaobei/dsh-codex-auth 3.0.6 → 3.0.7

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.
Files changed (2) hide show
  1. package/lib/client.js +17 -6
  2. package/package.json +1 -1
package/lib/client.js CHANGED
@@ -336,16 +336,27 @@ window.__ModuleLoader__.load({
336
336
  mark();
337
337
  return () => { observer.disconnect(); marked.forEach(button => button.classList.remove("codex-auth-nav")); };
338
338
  }, "dsh-codex-auth: ChatGPT navigation icon");
339
- // ---- plugin detail page (plugins.bundle.config) ----
340
- // 参考 dsh-context:配置命名空间由 configForms 服务托管;没有该服务时直接注册。
339
+ // ---- plugin detail page (plugins.bundle.config, same as dsh-context) ----
340
+ const settingsStore = (() => {
341
+ let form; let state = {}; const listeners = new Set();
342
+ const notify = () => listeners.forEach((fn) => fn());
343
+ return {
344
+ get state() { return state; },
345
+ subscribe(fn) { listeners.add(fn); return () => listeners.delete(fn); },
346
+ attach(f) { form = f; try { state = { ...state, ...(f && f.get ? f.get() : {}) }; } catch {} notify(); let un; try { un = f.subscribe(() => { try { state = { ...state, ...(f.get ? f.get() : {}) }; } catch {} notify(); }); } catch {} return () => { if (un) un(); if (form === f) form = undefined; }; },
347
+ set(k, v) { state = { ...state, [k]: v }; notify(); if (form && typeof form.set === "function") form.set(k, v).catch(() => {}); },
348
+ };
349
+ })();
341
350
  const registerPluginsPageCard = (env) => {
342
351
  const cf = env && env.configForms;
343
- const serve = cf && typeof cf.whileServed === "function" ? (fn) => cf.whileServed([NS], fn) : (fn) => fn();
344
- serve(() => ctx.slots.inject("plugins.bundle.config", () => ctx.slots.register({
352
+ if (!cf || typeof cf.get !== "function" || typeof cf.whileServed !== "function") return;
353
+ ctx.effect(() => settingsStore.attach(cf.get(NS)), "dsh-codex-auth: config forms");
354
+ ctx.effect(() => cf.whileServed([NS], () => ctx.slots.inject("plugins.bundle.config", () => ctx.slots.register({
345
355
  name: "plugins.bundle.config",
346
356
  key: NS,
347
- locale: NS
348
- }, () => React.createElement(StatusCard, { t: t, call: call }))));
357
+ locale: NS,
358
+ inject: () => ({ hooks: { codexAuth: settingsStore }, set: (k, v) => settingsStore.set(k, v) })
359
+ }, () => React.createElement(StatusCard, { t: t, call: call })))), "dsh-codex-auth: plugins-page card");
349
360
  };
350
361
  if (typeof ctx.inject === "function") ctx.inject(["configForms"], registerPluginsPageCard);
351
362
  else registerPluginsPageCard(ctx);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sunshaobei/dsh-codex-auth",
3
3
  "description": "Codex 订阅授权管理 for the dsh web surface: a dedicated settings page (authorization status, validity/expiry, one-click browser OAuth) plus an expired-credential modal when a GPT model is selected. Host half runs the full OpenAI OAuth flow (PKCE S256, localhost:1455 callback) and writes the llm-pi-ai/openai-codex grant record through ctx.credentials.",
4
- "version": "3.0.6",
4
+ "version": "3.0.7",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/index.d.ts",