Merge branch 'dev' of https://github.com/QLHazyCoder/codex-oauth-automation-extension into dev
This commit is contained in:
@@ -6,6 +6,8 @@
|
||||
addLog: rawAddLog = async () => {},
|
||||
ensureStep8SignupPageReady,
|
||||
fetchImpl = (...args) => fetch(...args),
|
||||
generateRandomBirthday,
|
||||
generateRandomName,
|
||||
getOAuthFlowStepTimeoutMs,
|
||||
getState,
|
||||
sendToContentScript,
|
||||
@@ -333,13 +335,13 @@
|
||||
return Math.max(500, Math.min(30000, parsed));
|
||||
}
|
||||
|
||||
function assertFiveSimMaxPriceCompatibleWithOperator(operator, maxPriceLimit) {
|
||||
const normalizedOperator = normalizeFiveSimCountryCode(operator, DEFAULT_FIVE_SIM_OPERATOR);
|
||||
if (maxPriceLimit !== null && maxPriceLimit !== undefined && normalizedOperator !== DEFAULT_FIVE_SIM_OPERATOR) {
|
||||
throw new Error('5sim maxPrice only works when operator is "any"; clear the price limit or switch operator to any before buying a number.');
|
||||
}
|
||||
}
|
||||
|
||||
function assertFiveSimMaxPriceCompatibleWithOperator(operator, maxPriceLimit) {
|
||||
const normalizedOperator = normalizeFiveSimCountryCode(operator, DEFAULT_FIVE_SIM_OPERATOR);
|
||||
if (maxPriceLimit !== null && maxPriceLimit !== undefined && normalizedOperator !== DEFAULT_FIVE_SIM_OPERATOR) {
|
||||
throw new Error('5sim maxPrice only works when operator is "any"; clear the price limit or switch operator to any before buying a number.');
|
||||
}
|
||||
}
|
||||
|
||||
function normalizeHeroSmsPriceLimit(value) {
|
||||
if (value === undefined || value === null || String(value).trim() === '') {
|
||||
return null;
|
||||
@@ -1460,19 +1462,19 @@
|
||||
if (!apiKey) {
|
||||
throw new Error('5sim API key is missing. Save it in the side panel before running the phone flow.');
|
||||
}
|
||||
const configuredMaxPrice = normalizeHeroSmsPriceLimit(state.fiveSimMaxPrice);
|
||||
const operator = normalizeFiveSimCountryCode(state.fiveSimOperator, DEFAULT_FIVE_SIM_OPERATOR);
|
||||
const maxPriceLimit = configuredMaxPrice !== null
|
||||
? configuredMaxPrice
|
||||
: normalizeHeroSmsPriceLimit(state.heroSmsMaxPrice);
|
||||
assertFiveSimMaxPriceCompatibleWithOperator(operator, maxPriceLimit);
|
||||
const configuredMaxPrice = normalizeHeroSmsPriceLimit(state.fiveSimMaxPrice);
|
||||
const operator = normalizeFiveSimCountryCode(state.fiveSimOperator, DEFAULT_FIVE_SIM_OPERATOR);
|
||||
const maxPriceLimit = configuredMaxPrice !== null
|
||||
? configuredMaxPrice
|
||||
: normalizeHeroSmsPriceLimit(state.heroSmsMaxPrice);
|
||||
assertFiveSimMaxPriceCompatibleWithOperator(operator, maxPriceLimit);
|
||||
return {
|
||||
provider,
|
||||
apiKey,
|
||||
baseUrl: normalizeUrl(state.fiveSimBaseUrl, DEFAULT_FIVE_SIM_BASE_URL).replace(/\/+$/, ''),
|
||||
operator,
|
||||
operator,
|
||||
product: normalizeFiveSimCountryCode(state.fiveSimProduct, DEFAULT_FIVE_SIM_PRODUCT),
|
||||
maxPriceLimit,
|
||||
maxPriceLimit,
|
||||
countryCandidates: resolveFiveSimCountryCandidates(state),
|
||||
};
|
||||
}
|
||||
@@ -3623,13 +3625,35 @@
|
||||
|
||||
async function submitPhoneVerificationCode(tabId, code) {
|
||||
const visibleStep = normalizeLogStep(activePhoneVerificationLogStep) || 9;
|
||||
const signupProfile = (
|
||||
typeof generateRandomName === 'function'
|
||||
&& typeof generateRandomBirthday === 'function'
|
||||
)
|
||||
? (() => {
|
||||
const name = generateRandomName();
|
||||
const birthday = generateRandomBirthday();
|
||||
if (!name?.firstName || !name?.lastName || !birthday) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
firstName: name.firstName,
|
||||
lastName: name.lastName,
|
||||
year: birthday.year,
|
||||
month: birthday.month,
|
||||
day: birthday.day,
|
||||
};
|
||||
})()
|
||||
: null;
|
||||
const timeoutMs = typeof getOAuthFlowStepTimeoutMs === 'function'
|
||||
? await getOAuthFlowStepTimeoutMs(45000, { step: visibleStep, actionLabel: '提交手机验证码' })
|
||||
: 45000;
|
||||
const result = await sendToContentScriptResilient('signup-page', {
|
||||
type: 'SUBMIT_PHONE_VERIFICATION_CODE',
|
||||
source: 'background',
|
||||
payload: { code },
|
||||
payload: {
|
||||
code,
|
||||
...(signupProfile ? { signupProfile } : {}),
|
||||
},
|
||||
}, {
|
||||
timeoutMs,
|
||||
responseTimeoutMs: timeoutMs,
|
||||
|
||||
Reference in New Issue
Block a user