dsh-codex-oauth 0.2.3 → 0.2.5

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/client/index.jsx CHANGED
@@ -22,12 +22,11 @@ function CodexSettings() {
22
22
  const timer = setInterval(refresh, 1000);
23
23
  return () => clearInterval(timer);
24
24
  }, [refresh, state.status]);
25
- const signIn = async () => {
25
+ const signIn = () => {
26
26
  setBusy(true); setState({ status: "signing-in" });
27
- const popup = window.open("about:blank", "_blank", "noopener,noreferrer");
28
- try { const challenge = await request(LOGIN, "POST"); if (!popup) throw new Error("Please allow popups to sign in"); popup.location.replace(challenge.url); }
29
- catch (error) { popup?.close(); setState({ status: "error", message: error.message }); }
30
- finally { setBusy(false); }
27
+ const popup = window.open(LOGIN, "_blank", "noopener,noreferrer");
28
+ if (!popup) { setBusy(false); setState({ status: "error", message: "Please allow popups to sign in" }); }
29
+ else setTimeout(() => setBusy(false), 500);
31
30
  };
32
31
  const signOut = async () => { setBusy(true); try { await request(LOGOUT, "POST"); setState({ status: "signed-out" }); } catch (error) { setState({ status: "error", message: error.message }); } finally { setBusy(false); } };
33
32
  const signedIn = state.status === "signed-in";
package/lib/adapter.js CHANGED
@@ -14,8 +14,9 @@ function tokenProvider(provider) {
14
14
  apiKey: {
15
15
  name: "OpenAI Codex OAuth bearer token",
16
16
  async resolve({ credential }) {
17
- return credential?.access
18
- ? { auth: { apiKey: credential.access }, source: "Pi OAuth" }
17
+ const access = credential?.access ?? credential?.key;
18
+ return access
19
+ ? { auth: { apiKey: access }, source: "DSH Codex OAuth" }
19
20
  : undefined;
20
21
  },
21
22
  },
package/lib/client.js CHANGED
@@ -58,20 +58,14 @@ function CodexSettings() {
58
58
  const timer = setInterval(refresh, 1e3);
59
59
  return () => clearInterval(timer);
60
60
  }, [refresh, state.status]);
61
- const signIn = async () => {
61
+ const signIn = () => {
62
62
  setBusy(true);
63
63
  setState({ status: "signing-in" });
64
- const popup = window.open("about:blank", "_blank", "noopener,noreferrer");
65
- try {
66
- const challenge = await request(LOGIN, "POST");
67
- if (!popup) throw new Error("Please allow popups to sign in");
68
- popup.location.replace(challenge.url);
69
- } catch (error) {
70
- popup?.close();
71
- setState({ status: "error", message: error.message });
72
- } finally {
64
+ const popup = window.open(LOGIN, "_blank", "noopener,noreferrer");
65
+ if (!popup) {
73
66
  setBusy(false);
74
- }
67
+ setState({ status: "error", message: "Please allow popups to sign in" });
68
+ } else setTimeout(() => setBusy(false), 500);
75
69
  };
76
70
  const signOut = async () => {
77
71
  setBusy(true);
package/lib/web-auth.js CHANGED
@@ -48,9 +48,14 @@ export function registerWebAuth(ctx, store) {
48
48
  json(res, 200, state);
49
49
  }}),
50
50
  web.webServer.register({ kind: "exact", path: AUTH_LOGIN_PATH, handler: async (req, res) => {
51
- if (req.method !== "POST" || !trusted(req)) return json(res, req.method === "POST" ? 403 : 405, { error: "forbidden" });
52
- try { start(); for (let i = 0; i < 50 && !challenge && operation; i++) await new Promise((resolve) => setTimeout(resolve, 100)); if (!challenge) throw new Error("OAuth URL was not created"); json(res, 200, challenge); }
53
- catch (error) { json(res, 500, { error: safeMessage(error) }); }
51
+ if (!trusted(req) || !["GET", "POST"].includes(req.method)) return json(res, req.method === "GET" || req.method === "POST" ? 403 : 405, { error: "forbidden" });
52
+ try {
53
+ start();
54
+ for (let i = 0; i < 50 && !challenge && operation; i++) await new Promise((resolve) => setTimeout(resolve, 100));
55
+ if (!challenge) throw new Error("OAuth URL was not created");
56
+ if (req.method === "GET") { res.writeHead(302, { location: challenge.url, "cache-control": "no-store" }); res.end(); }
57
+ else json(res, 200, challenge);
58
+ } catch (error) { json(res, 500, { error: safeMessage(error) }); }
54
59
  }}),
55
60
  web.webServer.register({ kind: "exact", path: AUTH_LOGOUT_PATH, handler: async (req, res) => {
56
61
  if (req.method !== "POST" || !trusted(req)) return json(res, req.method === "POST" ? 403 : 405, { error: "forbidden" });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-codex-oauth",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "description": "Use a ChatGPT Codex subscription in DeepSeek Harness through standalone OAuth",
5
5
  "repository": {
6
6
  "type": "git",