From d75abcf6a737854272dae094cc9af691a807b3c6 Mon Sep 17 00:00:00 2001 From: Vladyslav Pashynskykh Date: Wed, 22 May 2024 13:02:11 +0300 Subject: [PATCH] Ente Auth: Add support for Steam domain used as issuer --- auth/lib/models/code.dart | 2 +- auth/lib/onboarding/view/setup_enter_secret_key_page.dart | 2 +- auth/lib/utils/totp_util.dart | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/auth/lib/models/code.dart b/auth/lib/models/code.dart index 7a7daf58d..112d508da 100644 --- a/auth/lib/models/code.dart +++ b/auth/lib/models/code.dart @@ -205,7 +205,7 @@ class Code { try { return int.parse(uri.queryParameters['digits']!); } catch (e) { - if (issuer.toLowerCase() == "steam") { + if (issuer.toLowerCase() == "steam" || issuer.toLowerCase().contains('steampowered.com')) { return steamDigits; } return defaultDigits; diff --git a/auth/lib/onboarding/view/setup_enter_secret_key_page.dart b/auth/lib/onboarding/view/setup_enter_secret_key_page.dart index 6741788c3..b4ab8bfd0 100644 --- a/auth/lib/onboarding/view/setup_enter_secret_key_page.dart +++ b/auth/lib/onboarding/view/setup_enter_secret_key_page.dart @@ -240,7 +240,7 @@ class _SetupEnterSecretKeyPageState extends State { final account = _accountController.text.trim(); final issuer = _issuerController.text.trim(); final secret = _secretController.text.trim().replaceAll(' ', ''); - final isStreamCode = issuer.toLowerCase() == "steam"; + final isStreamCode = issuer.toLowerCase() == "steam" || issuer.toLowerCase().contains('steampowered.com'); if (widget.code != null && widget.code!.secret != secret) { ButtonResult? result = await showChoiceActionSheet( context, diff --git a/auth/lib/utils/totp_util.dart b/auth/lib/utils/totp_util.dart index 1b0c874bd..61c7f20e9 100644 --- a/auth/lib/utils/totp_util.dart +++ b/auth/lib/utils/totp_util.dart @@ -4,7 +4,7 @@ import 'package:otp/otp.dart' as otp; import 'package:steam_totp/steam_totp.dart'; String getOTP(Code code) { - if (['steam', 'steampowered.com'].contains(code.issuer.toLowerCase())) { + if (code.type == Type.steam) { return _getSteamCode(code); } if (code.type == Type.hotp) { @@ -39,7 +39,7 @@ String _getSteamCode(Code code, [bool isNext = false]) { } String getNextTotp(Code code) { - if (['steam', 'steampowered.com'].contains(code.issuer.toLowerCase())) { + if (code.type == Type.steam) { return _getSteamCode(code, true); } return otp.OTP.generateTOTPCodeString(