mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-12-23 18:22:39 +03:00
Fix parsing of otpauth-migration
Uri.
This solves the issue regarding duplicate accounts not being recognized.
This commit is contained in:
parent
73a5e4aa6b
commit
87b463f4e8
@ -188,22 +188,30 @@ class CredentialData with _$CredentialData {
|
|||||||
|
|
||||||
// Convert parsed credential values into CredentialData objects
|
// Convert parsed credential values into CredentialData objects
|
||||||
return splitCreds(base64.decode(uri.queryParameters['data']!))
|
return splitCreds(base64.decode(uri.queryParameters['data']!))
|
||||||
.map((values) => CredentialData(
|
.map((values) {
|
||||||
secret: base32.encode(values[1]),
|
String? issuer;
|
||||||
name: utf8.decode(values[2], allowMalformed: true),
|
String name = utf8.decode(values[2], allowMalformed: true);
|
||||||
issuer: values[3] != null
|
final nameIndex = name.indexOf(':');
|
||||||
? utf8.decode(values[3], allowMalformed: true)
|
if (nameIndex >= 0) {
|
||||||
: null,
|
issuer = name.substring(0, nameIndex);
|
||||||
hashAlgorithm: switch (values[4]) {
|
name = name.substring(nameIndex + 1);
|
||||||
2 => HashAlgorithm.sha256,
|
}
|
||||||
3 => HashAlgorithm.sha512,
|
return CredentialData(
|
||||||
_ => HashAlgorithm.sha1,
|
secret: base32.encode(values[1]),
|
||||||
},
|
name: name,
|
||||||
digits: values[5] == 2 ? 8 : defaultDigits,
|
issuer: values[3] != null
|
||||||
oathType: values[6] == 1 ? OathType.hotp : OathType.totp,
|
? utf8.decode(values[3], allowMalformed: true)
|
||||||
counter: values[7] ?? defaultCounter,
|
: issuer,
|
||||||
))
|
hashAlgorithm: switch (values[4]) {
|
||||||
.toList();
|
2 => HashAlgorithm.sha256,
|
||||||
|
3 => HashAlgorithm.sha512,
|
||||||
|
_ => HashAlgorithm.sha1,
|
||||||
|
},
|
||||||
|
digits: values[5] == 2 ? 8 : defaultDigits,
|
||||||
|
oathType: values[6] == 1 ? OathType.hotp : OathType.totp,
|
||||||
|
counter: values[7] ?? defaultCounter,
|
||||||
|
);
|
||||||
|
}).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
factory CredentialData.fromOtpauth(Uri uri) {
|
factory CredentialData.fromOtpauth(Uri uri) {
|
||||||
|
Loading…
Reference in New Issue
Block a user