MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / completeOAuthConsent

Function completeOAuthConsent

e2e/src/clients/opencode.ts:125–141  ·  view source on GitHub ↗
(
  home: OpenCodeHome,
  email: string,
  sinceIndex: number,
)

Source from the content-addressed store, hash-verified

123 * code straight to OpenCode's localhost callback.
124 */
125export const completeOAuthConsent = async (
126 home: OpenCodeHome,
127 email: string,
128 sinceIndex: number,
129): Promise<void> => {
130 const deadline = Date.now() + 30_000;
131 while (Date.now() < deadline) {
132 const url = home.openedUrls()[sinceIndex];
133 if (url) {
134 const response = await fetch(`${url}&login_hint=${encodeURIComponent(email)}`);
135 if (!response.ok) throw new Error(`consent redirect chain failed (${response.status})`);
136 return;
137 }
138 await new Promise((tick) => setTimeout(tick, 250));
139 }
140 throw new Error("opencode never opened an authorization URL");
141};

Callers

nothing calls this directly

Calls 1

fetchFunction · 0.50

Tested by

no test coverage detected