MCPcopy Create free account
hub / github.com/QLHazyCoder/FlowPilot / executeStep6

Function executeStep6

background/steps/oauth-login.js:23–104  ·  view source on GitHub ↗
(state, options = {})

Source from the content-addressed store, hash-verified

21 } = deps;
22
23 async function executeStep6(state, options = {}) {
24 const { skipPreLoginCleanup = false } = options;
25 if (shouldSkipLoginVerificationForCpaCallback(state)) {
26 await skipLoginVerificationStepsForCpaCallback();
27 return;
28 }
29 if (!state.email) {
30 throw new Error('缺少邮箱地址,请先完成步骤 3。');
31 }
32
33 if (!skipPreLoginCleanup) {
34 await runPreStep6CookieCleanup();
35 }
36
37 let attempt = 0;
38 let lastError = null;
39
40 while (attempt < STEP6_MAX_ATTEMPTS) {
41 throwIfStopped();
42 attempt += 1;
43 try {
44 const currentState = attempt === 1 ? state : await getState();
45 const password = currentState.password || currentState.customPassword || '';
46 const oauthUrl = await refreshOAuthUrlBeforeStep6(currentState);
47
48 if (attempt === 1) {
49 await addLog('步骤 6:正在打开最新 OAuth 链接并登录...');
50 } else {
51 await addLog(`步骤 6:上一轮失败后,正在进行第 ${attempt} 次尝试(最多 ${STEP6_MAX_ATTEMPTS} 次)...`, 'warn');
52 }
53
54 await reuseOrCreateTab('signup-page', oauthUrl);
55
56 const result = await sendToContentScriptResilient(
57 'signup-page',
58 {
59 type: 'EXECUTE_STEP',
60 step: 6,
61 source: 'background',
62 payload: {
63 email: currentState.email,
64 password,
65 },
66 },
67 {
68 timeoutMs: 180000,
69 retryDelayMs: 700,
70 logMessage: '步骤 6:认证页正在切换,等待页面重新就绪后继续登录...',
71 }
72 );
73
74 if (result?.error) {
75 throw new Error(result.error);
76 }
77
78 if (isStep6SuccessResult(result)) {
79 await completeStepFromBackground(6, {
80 loginVerificationRequestedAt: result.loginVerificationRequestedAt || null,

Callers 1

Calls 14

runPreStep6CookieCleanupFunction · 0.85
getStateFunction · 0.85
isStep6SuccessResultFunction · 0.85
isStep6RecoverableResultFunction · 0.85
throwIfStoppedFunction · 0.50
addLogFunction · 0.50
reuseOrCreateTabFunction · 0.50

Tested by

no test coverage detected