π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Fix: Capitalize algorithm parameter in QR codes for Google Authenticator compatibility
Prateek Sunal42f37cb7c776
diff --git a/mobile/apps/auth/lib/models/code.dart b/mobile/apps/auth/lib/models/code.dartindex 452ae4e3f3..8e9ce619ed 100644--- a/mobile/apps/auth/lib/models/code.dart+++ b/mobile/apps/auth/lib/models/code.dart@@ -115,6 +115,7 @@ class Code {int digits, {Algorithm algorithm = Algorithm.sha1,int period = defaultPeriod,+ int? generatedID,}) {final String encodedIssuer = Uri.encodeQueryComponent(issuer);return Code(@@ -127,6 +128,7 @@ class Code {type,0,"otpauth://${type.name}/$issuer:$account?algorithm=${algorithm.name.toUpperCase()}&digits=$digits&issuer=$encodedIssuer&period=$period&secret=$secret",+ generatedID: generatedID,display: display ?? CodeDisplay(),);}diff --git a/mobile/apps/auth/lib/onboarding/view/setup_enter_secret_key_page.dart b/mobile/apps/auth/lib/onboarding/view/setup_enter_secret_key_page.dartindex 60cc814a9a..88726e6b59 100644--- a/mobile/apps/auth/lib/onboarding/view/setup_enter_secret_key_page.dart+++ b/mobile/apps/auth/lib/onboarding/view/setup_enter_secret_key_page.dart@@ -458,27 +458,23 @@ class _SetupEnterSecretKeyPageState extends State<SetupEnterSecretKeyPage> {}}- final Code newCode = widget.code == null- ? Code.fromAccountAndSecret(- isStreamCode ? Type.steam : _type,- account,- issuer,- secret,- display,- isStreamCode ? Code.steamDigits : digits!,- algorithm: _algorithm,- period: period!,- )- : widget.code!.copyWith(- account: account,- issuer: issuer,- secret: secret,- display: display,- algorithm: _algorithm,- digits: digits!,- type: _type,- period: period,- );+ // When editing, preserve original type/algorithm/digits/period+ // When creating new, apply isStreamCode logic and use UI values+ final Code newCode = Code.fromAccountAndSecret(+ widget.code != null+ ? widget.code!.type+ : (isStreamCode ? Type.steam : _type),+ account,+ issuer,+ secret,+ display,+ widget.code != null+ ? widget.code!.digits+ : (isStreamCode ? Code.steamDigits : digits!),+ algorithm: widget.code?.algorithm ?? _algorithm,+ period: widget.code?.period ?? period!,+ generatedID: widget.code?.generatedID,+ );// Verify the validity of the codegetOTP(newCode);diff --git a/mobile/apps/auth/lib/onboarding/view/view_qr_page.dart b/mobile/apps/auth/lib/onboarding/view/view_qr_page.dartindex ea088ca7e6..3963746c01 100644--- a/mobile/apps/auth/lib/onboarding/view/view_qr_page.dart+++ b/mobile/apps/auth/lib/onboarding/view/view_qr_page.dart@@ -29,7 +29,10 @@ class ViewQrPage extends StatelessWidget {children: [QrImageView(data: code!.rawData- .replaceAll('algorithm=Algorithm.', 'algorithm='),+ .replaceAll('algorithm=Algorithm.', 'algorithm=')+ .replaceAll('algorithm=sha1', 'algorithm=SHA1')+ .replaceAll('algorithm=sha256', 'algorithm=SHA256')+ .replaceAll('algorithm=sha512', 'algorithm=SHA512'),eyeStyle: QrEyeStyle(eyeShape: QrEyeShape.square,color: Theme.of(context).colorScheme.onSurface,diff --git a/mobile/apps/auth/lib/ui/settings/data/html_export.dart b/mobile/apps/auth/lib/ui/settings/data/html_export.dartindex 09c660a6a6..8469a8361f 100644--- a/mobile/apps/auth/lib/ui/settings/data/html_export.dart+++ b/mobile/apps/auth/lib/ui/settings/data/html_export.dart@@ -48,7 +48,13 @@ Future<String> generateQRImageBase64(String data) async {}Future<String> generateOTPEntryHtml(Code code, BuildContext context) async {- final qrBase64 = await generateQRImageBase64(code.rawData);+ // Capitalize algorithm for Google Authenticator compatibility in QR codes+ final qrData = code.rawData+ .replaceAll('algorithm=Algorithm.', 'algorithm=')+ .replaceAll('algorithm=sha1', 'algorithm=SHA1')+ .replaceAll('algorithm=sha256', 'algorithm=SHA256')+ .replaceAll('algorithm=sha512', 'algorithm=SHA512');+ final qrBase64 = await generateQRImageBase64(qrData);String notes = code.display.note;if (notes.isNotEmpty) {notes = '<p class="group">Note: <b>$notes</b></p>';