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

Function pollFreshVerificationCode

background/verification-flow.js:245–345  ·  view source on GitHub ↗
(step, state, mail, pollOverrides = {})

Source from the content-addressed store, hash-verified

243 }
244
245 async function pollFreshVerificationCode(step, state, mail, pollOverrides = {}) {
246 const { onResendRequestedAt, ...cleanPollOverrides } = pollOverrides;
247
248 if (mail.provider === HOTMAIL_PROVIDER) {
249 const hotmailPollConfig = getHotmailVerificationPollConfig(step);
250 return pollHotmailVerificationCode(step, state, {
251 ...getVerificationPollPayload(step, state),
252 ...hotmailPollConfig,
253 ...cleanPollOverrides,
254 });
255 }
256 if (mail.provider === LUCKMAIL_PROVIDER) {
257 return pollLuckmailVerificationCode(step, state, {
258 ...getVerificationPollPayload(step, state),
259 ...pollOverrides,
260 });
261 }
262 if (mail.provider === CLOUDFLARE_TEMP_EMAIL_PROVIDER) {
263 return pollCloudflareTempEmailVerificationCode(step, state, {
264 ...getVerificationPollPayload(step, state),
265 ...pollOverrides,
266 });
267 }
268
269 if (Number(pollOverrides.resendIntervalMs) > 0) {
270 return pollFreshVerificationCodeWithResendInterval(step, state, mail, pollOverrides);
271 }
272
273 const stateKey = getVerificationCodeStateKey(step);
274 const rejectedCodes = new Set();
275 if (state[stateKey]) {
276 rejectedCodes.add(state[stateKey]);
277 }
278 for (const code of (pollOverrides.excludeCodes || [])) {
279 if (code) rejectedCodes.add(code);
280 }
281
282 let lastError = null;
283 let filterAfterTimestamp = cleanPollOverrides.filterAfterTimestamp ?? getVerificationPollPayload(step, state).filterAfterTimestamp;
284 const maxRounds = pollOverrides.maxRounds || VERIFICATION_POLL_MAX_ROUNDS;
285
286 for (let round = 1; round <= maxRounds; round++) {
287 throwIfStopped();
288 if (round > 1) {
289 const requestedAt = await requestVerificationCodeResend(step);
290 if (typeof onResendRequestedAt === 'function') {
291 const nextFilterAfterTimestamp = await onResendRequestedAt(requestedAt);
292 if (nextFilterAfterTimestamp !== undefined) {
293 filterAfterTimestamp = nextFilterAfterTimestamp;
294 }
295 }
296 }
297
298 const payload = getVerificationPollPayload(step, state, {
299 ...cleanPollOverrides,
300 filterAfterTimestamp,
301 excludeCodes: [...rejectedCodes],
302 });

Callers 1

resolveVerificationStepFunction · 0.70

Tested by

no test coverage detected