MCPcopy Index your code
hub / github.com/QLHazyCoder/FlowPilot / executeStep8

Function executeStep8

background/steps/confirm-oauth.js:35–168  ·  view source on GitHub ↗
(state)

Source from the content-addressed store, hash-verified

33 } = deps;
34
35 async function executeStep8(state) {
36 if (!state.oauthUrl) {
37 throw new Error('缺少登录用 OAuth 链接,请先完成步骤 6。');
38 }
39
40 await addLog('步骤 8:正在监听 localhost 回调地址...');
41
42 return new Promise((resolve, reject) => {
43 let resolved = false;
44 let signupTabId = null;
45
46 const cleanupListener = () => {
47 cleanupStep8NavigationListeners();
48 setStep8PendingReject(null);
49 };
50
51 const rejectStep8 = (error) => {
52 if (resolved) return;
53 resolved = true;
54 clearTimeout(timeout);
55 cleanupListener();
56 reject(error);
57 };
58
59 const finalizeStep8Callback = (callbackUrl) => {
60 if (resolved || !callbackUrl) return;
61
62 resolved = true;
63 cleanupListener();
64 clearTimeout(timeout);
65
66 addLog(`步骤 8:已捕获 localhost 地址:${callbackUrl}`, 'ok').then(() => {
67 return completeStepFromBackground(8, { localhostUrl: callbackUrl });
68 }).then(() => {
69 resolve();
70 }).catch((err) => {
71 reject(err);
72 });
73 };
74
75 const timeout = setTimeout(() => {
76 rejectStep8(new Error('120 秒内未捕获到 localhost 回调跳转,步骤 8 的点击可能被拦截了。'));
77 }, 120000);
78
79 setStep8PendingReject((error) => {
80 rejectStep8(error);
81 });
82
83 setWebNavListener((details) => {
84 const callbackUrl = getStep8CallbackUrlFromNavigation(details, signupTabId);
85 finalizeStep8Callback(callbackUrl);
86 });
87
88 setWebNavCommittedListener((details) => {
89 const callbackUrl = getStep8CallbackUrlFromNavigation(details, signupTabId);
90 finalizeStep8Callback(callbackUrl);
91 });
92

Callers

nothing calls this directly

Calls 15

rejectStep8Function · 0.85
setStep8PendingRejectFunction · 0.85
setWebNavListenerFunction · 0.85
finalizeStep8CallbackFunction · 0.85
waitForStep8ReadyFunction · 0.85
sleepWithStopFunction · 0.85
clickWithDebuggerFunction · 0.85

Tested by

no test coverage detected