fix: support MFA login via structured auth endpoint

This commit is contained in:
Linus Rath
2026-06-28 19:53:08 +02:00
parent f8b8e0b108
commit 63e087f3ef
3 changed files with 232 additions and 204 deletions
+4 -1
View File
@@ -702,7 +702,10 @@ export class JMAPClient implements IJMAPClient {
if (sessionResponse.status === 402) {
try {
const body = await sessionResponse.json();
if (body?.title?.toLowerCase().includes('totp')) {
// Older Stalwart titled this "TOTP code required"; 0.16+ uses the
// generic "MFA code required" - accept either to trigger the prompt.
const title = body?.title?.toLowerCase() ?? '';
if (title.includes('totp') || title.includes('mfa')) {
throw new Error('TOTP_REQUIRED');
}
} catch (e) {