Skip to content

Commit 09b8fd3

Browse files
committed
style: prettier format fix for CI
Auto-format files touched in the subscription auth fix: - src/background.js, src/oauth-anthropic.js, src/oauth-openai.js - tests/oauth-openai.test.js
1 parent 45c258c commit 09b8fd3

4 files changed

Lines changed: 26 additions & 6 deletions

File tree

src/background.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1711,7 +1711,11 @@ async function callOpenAIOAuth(model = 'gpt-5.4', prompt) {
17111711
}
17121712
const detail = await res.text().catch(() => '');
17131713
let msg;
1714-
try { msg = JSON.parse(detail)?.error?.message; } catch { msg = ''; }
1714+
try {
1715+
msg = JSON.parse(detail)?.error?.message;
1716+
} catch {
1717+
msg = '';
1718+
}
17151719
throw new Error(msg || `OpenAI Codex API error ${res.status}`);
17161720
}
17171721

@@ -1750,7 +1754,11 @@ async function parseCodexResponsesSSE(response, timeoutMs = 60_000) {
17501754
for (const data of dataLines) {
17511755
if (data === '[DONE]') continue;
17521756
let evt;
1753-
try { evt = JSON.parse(data); } catch { continue; }
1757+
try {
1758+
evt = JSON.parse(data);
1759+
} catch {
1760+
continue;
1761+
}
17541762
if (evt.type === 'response.output_text.delta' && typeof evt.delta === 'string') {
17551763
fullText += evt.delta;
17561764
}

src/oauth-anthropic.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ async function fetchWithRetry(url, opts, { maxRetries = 2, baseDelayMs = 2000 }
7171
if (res.status !== 429) return res;
7272
// Rate limited — read retry hint and back off
7373
const retryAfter = res.headers.get('retry-after');
74-
const delay = retryAfter ? Math.max(1000, Number(retryAfter) * 1000) : baseDelayMs * (2 ** attempt);
74+
const delay = retryAfter ? Math.max(1000, Number(retryAfter) * 1000) : baseDelayMs * 2 ** attempt;
7575
if (attempt < maxRetries) {
7676
await _sleep(Math.min(delay, 30000));
7777
continue;
@@ -80,7 +80,7 @@ async function fetchWithRetry(url, opts, { maxRetries = 2, baseDelayMs = 2000 }
8080
} catch (err) {
8181
lastErr = err;
8282
if (attempt < maxRetries) {
83-
await _sleep(baseDelayMs * (2 ** attempt));
83+
await _sleep(baseDelayMs * 2 ** attempt);
8484
continue;
8585
}
8686
throw err;

src/oauth-openai.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,14 @@ async function tokenErrorMessage(res, fallback) {
224224
const body = await res.text().catch(() => '');
225225
try {
226226
const e = JSON.parse(body);
227-
return e.error_description || e.error?.message || e.error || e.message || fallback || `Token request failed (${res.status})`;
227+
return (
228+
e.error_description ||
229+
e.error?.message ||
230+
e.error ||
231+
e.message ||
232+
fallback ||
233+
`Token request failed (${res.status})`
234+
);
228235
} catch {
229236
// body isn't JSON — if it's an object stringified somehow, stringify it properly
230237
if (body && typeof body === 'object') return JSON.stringify(body).slice(0, 160);

tests/oauth-openai.test.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,12 @@ describe('mintOpenAIApiKey', () => {
254254

255255
describe('waitForOpenAIOAuthResult', () => {
256256
it('resolves with ok once OAuth credentials appear', async () => {
257-
store[OPENAI_CREDENTIALS_KEY] = { access_token: 'acc', refresh_token: 'ref', id_token: 'id', expires_at: Date.now() + 3600000 };
257+
store[OPENAI_CREDENTIALS_KEY] = {
258+
access_token: 'acc',
259+
refresh_token: 'ref',
260+
id_token: 'id',
261+
expires_at: Date.now() + 3600000,
262+
};
258263
const r = await waitForOpenAIOAuthResult({ timeoutMs: 1000, intervalMs: 10 });
259264
expect(r).toEqual({ ok: true });
260265
});

0 commit comments

Comments
 (0)