fix: 支持新版 ChatGPT 登录验证码邮件匹配

This commit is contained in:
Ryan Liu
2026-04-24 18:06:13 +08:00
parent 9c1c0bc076
commit 70f3ffb266
13 changed files with 95 additions and 4 deletions
+10
View File
@@ -181,6 +181,7 @@ test('shouldClearHotmailCurrentSelection returns true only when account becomes
test('extractVerificationCode returns first six-digit code from multilingual mail text', () => {
assert.equal(extractVerificationCode('你的 ChatGPT 验证码为 370794,请勿泄露。'), '370794');
assert.equal(extractVerificationCode('Your verification code is 654321.'), '654321');
assert.equal(extractVerificationCode('ChatGPT Log-in Code\nIf that was you, enter this code:\n\n982219'), '982219');
assert.equal(extractVerificationCode('No code here'), null);
});
@@ -202,6 +203,15 @@ test('extractVerificationCodeFromMessage reads code from the latest message subj
}),
'654321'
);
assert.equal(
extractVerificationCodeFromMessage({
subject: 'ChatGPT Log-in Code',
bodyPreview: 'We noticed a suspicious log-in on your account. If that was you, enter this code:\n\n982219',
from: { emailAddress: { address: 'noreply@openai.com' } },
}),
'982219'
);
});
test('getHotmailListToggleLabel reflects expanded state and account count', () => {
+14
View File
@@ -81,6 +81,20 @@ return { readOpenedMailBody, extractVerificationCode };
assert.equal(api.extractVerificationCode(bodyText), '731091');
});
test('extractVerificationCode matches the new suspicious log-in mail body', () => {
const bundle = [
extractFunction('extractVerificationCode'),
].join('\n');
const api = new Function(`
${bundle}
return { extractVerificationCode };
`)();
const bodyText = 'ChatGPT Log-in Code\nWe noticed a suspicious log-in on your account. If that was you, enter this code:\n\n982219';
assert.equal(api.extractVerificationCode(bodyText), '982219');
});
test('readOpenedMailBody ignores conversation list rows when no detail pane is open', () => {
const bundle = [
extractFunction('normalizeText'),
+14
View File
@@ -68,6 +68,20 @@ test('normalizeLuckmailTokenCode and normalizeLuckmailTokenMail extract verifica
assert.equal(normalizedMail.verification_code, '654321');
assert.equal(extractLuckmailVerificationCode('你的验证码为 778899'), '778899');
assert.equal(
extractLuckmailVerificationCode('ChatGPT Log-in Code\nIf that was you, enter this code:\n\n982219'),
'982219'
);
const suspiciousLoginMail = normalizeLuckmailTokenMail({
message_id: 'mail-3',
from: 'noreply@openai.com',
subject: 'ChatGPT Log-in Code',
body: 'We noticed a suspicious log-in on your account. If that was you, enter this code:\n\n982219',
received_at: '2026-04-14T10:02:00Z',
});
assert.equal(suspiciousLoginMail.verification_code, '982219');
});
test('normalizeLuckmailProjectName and isLuckmailPurchaseForProject match openai case-insensitively', () => {
+14
View File
@@ -340,6 +340,20 @@ return { openMailAndGetMessageText, mailItem };
assert.doesNotMatch(text, /111111/);
});
test('extractVerificationCode matches the new suspicious log-in mail body', () => {
const bundle = [
extractFunction('extractVerificationCode'),
].join('\n');
const api = new Function(`
${bundle}
return { extractVerificationCode };
`)();
const bodyText = 'ChatGPT Log-in Code\nWe noticed a suspicious log-in on your account. If that was you, enter this code:\n\n982219';
assert.equal(api.extractVerificationCode(bodyText), '982219');
});
test('handlePollEmail ignores same-minute old snapshot mail before fallback', async () => {
const bundle = [
extractFunction('normalizeText'),
+15
View File
@@ -546,6 +546,21 @@ return {
]);
});
test('extractVerificationCode strict mode matches the new suspicious log-in mail body', () => {
const bundle = [
extractFunction('extractVerificationCode'),
].join('\n');
const api = new Function(`
${bundle}
return { extractVerificationCode };
`)();
const bodyText = 'ChatGPT Log-in Code\nWe noticed a suspicious log-in on your account. If that was you, enter this code:\n\n982219';
assert.equal(api.extractVerificationCode(bodyText, true), '982219');
assert.equal(api.extractVerificationCode(bodyText, false), '982219');
});
test('openMailAndGetMessageText always returns to inbox after opening a 2925 message', async () => {
const bundle = [
extractFunction('returnToInbox'),