(state)
| 120 | } |
| 121 | |
| 122 | async function executeStep7(state) { |
| 123 | if (shouldSkipLoginVerificationForCpaCallback(state)) { |
| 124 | await setState({ |
| 125 | lastLoginCode: null, |
| 126 | loginVerificationRequestedAt: null, |
| 127 | }); |
| 128 | await setStepStatus(7, 'skipped'); |
| 129 | await addLog('步骤 7:当前已选择“第六步回调”,本轮无需获取登录验证码。', 'warn'); |
| 130 | return; |
| 131 | } |
| 132 | |
| 133 | let currentState = state; |
| 134 | let mailPollingAttempt = 1; |
| 135 | let lastMailPollingError = null; |
| 136 | |
| 137 | while (true) { |
| 138 | try { |
| 139 | await runStep7Attempt(currentState); |
| 140 | return; |
| 141 | } catch (err) { |
| 142 | if (!isVerificationMailPollingError(err)) { |
| 143 | throw err; |
| 144 | } |
| 145 | |
| 146 | lastMailPollingError = err; |
| 147 | if (mailPollingAttempt >= STEP7_MAIL_POLLING_RECOVERY_MAX_ATTEMPTS) { |
| 148 | break; |
| 149 | } |
| 150 | |
| 151 | mailPollingAttempt += 1; |
| 152 | await addLog( |
| 153 | `步骤 7:检测到邮箱轮询类失败,准备从步骤 6 重新开始(${mailPollingAttempt}/${STEP7_MAIL_POLLING_RECOVERY_MAX_ATTEMPTS})...`, |
| 154 | 'warn' |
| 155 | ); |
| 156 | await rerunStep6ForStep7Recovery(); |
| 157 | currentState = await getState(); |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | if (lastMailPollingError) { |
| 162 | throw new Error( |
| 163 | `步骤 7:登录验证码流程在 ${STEP7_MAIL_POLLING_RECOVERY_MAX_ATTEMPTS} 轮邮箱轮询恢复后仍未成功。最后一次原因:${lastMailPollingError.message}` |
| 164 | ); |
| 165 | } |
| 166 | |
| 167 | throw new Error('步骤 7:登录验证码流程未成功完成。'); |
| 168 | } |
| 169 | |
| 170 | return { executeStep7 }; |
| 171 | } |
nothing calls this directly
no test coverage detected