Skip to content

Commit 9a527a1

Browse files
authored
[auth] Fix export with invalid algo name (#4712)
## Description Fixes #4404 ## Tests
2 parents a1779af + ab3589a commit 9a527a1

File tree

5 files changed

+9
-7
lines changed

5 files changed

+9
-7
lines changed

auth/lib/models/code.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,9 @@ class Code {
256256
try {
257257
final algorithm =
258258
uri.queryParameters['algorithm'].toString().toLowerCase();
259-
if (algorithm == "sha256") {
259+
if (algorithm == "sha256" || "algorithm.sha256" == algorithm) {
260260
return Algorithm.sha256;
261-
} else if (algorithm == "sha512") {
261+
} else if (algorithm == "sha512" || "algorithm.sha512" == algorithm) {
262262
return Algorithm.sha512;
263263
}
264264
} catch (e) {

auth/lib/onboarding/view/view_qr_page.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ class ViewQrPage extends StatelessWidget {
2828
child: Column(
2929
children: [
3030
QrImageView(
31-
data: code!.rawData,
31+
data: code!.rawData
32+
.replaceAll('algorithm=Algorithm.', 'algorithm='),
3233
eyeStyle: QrEyeStyle(
3334
eyeShape: QrEyeShape.square,
3435
color: Theme.of(context).colorScheme.onSurface,

auth/lib/ui/settings/data/export_widget.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ Future<String> _getAuthDataForExport() async {
189189
String data = "";
190190
for (final code in allCodes) {
191191
if (code.hasError) continue;
192-
data += "${code.rawData.replaceAll(',', '%2C')}\n";
192+
data +=
193+
"${code.rawData.replaceAll('algorithm=Algorithm.', 'algorithm=').replaceAll(',', '%2C')}\n";
193194
}
194195

195196
return data;

auth/lib/ui/settings/data/import/google_auth_import.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,10 @@ List<Code> parseGoogleAuth(String qrCodeData) {
118118
if (otpParameter.type == MigrationPayload_OtpType.OTP_TYPE_TOTP ||
119119
otpParameter.type == MigrationPayload_OtpType.OTP_TYPE_UNSPECIFIED) {
120120
otpUrl =
121-
'otpauth://totp/$issuer:$account?secret=$secret&issuer=$issuer&algorithm=$algorithm&digits=$digits&period=$timer';
121+
'otpauth://totp/$issuer:$account?secret=$secret&issuer=$issuer&algorithm=${algorithm.name}&digits=$digits&period=$timer';
122122
} else if (otpParameter.type == MigrationPayload_OtpType.OTP_TYPE_HOTP) {
123123
otpUrl =
124-
'otpauth://hotp/$issuer:$account?secret=$secret&issuer=$issuer&algorithm=$algorithm&digits=$digits&counter=$counter';
124+
'otpauth://hotp/$issuer:$account?secret=$secret&issuer=$issuer&algorithm=${algorithm.name}&digits=$digits&counter=$counter';
125125
} else {
126126
throw Exception('Invalid OTP type');
127127
}

auth/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
name: ente_auth
33
description: ente two-factor authenticator
4-
version: 4.2.6+426
4+
version: 4.2.7+427
55
publish_to: none
66

77
environment:

0 commit comments

Comments
 (0)