commit
d66a5db998
9 changed files with 35 additions and 12 deletions
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"@@locale": "en",
|
||||
"@@locale": "de",
|
||||
"counterAppBarTitle": "Zähler",
|
||||
"@counterAppBarTitle": {
|
||||
"description": "Text shown in the AppBar of the Counter Page"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"@@locale": "en",
|
||||
"@@locale": "es",
|
||||
"counterAppBarTitle": "Contador",
|
||||
"@counterAppBarTitle": {
|
||||
"description": "Text shown in the AppBar of the Counter Page"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"@@locale": "en",
|
||||
"@@locale": "fr",
|
||||
"counterAppBarTitle": "Compteur",
|
||||
"@counterAppBarTitle": {
|
||||
"description": "Text shown in the AppBar of the Counter Page"
|
||||
|
@ -86,7 +86,7 @@
|
|||
"recoverAccount": "Récupérer un compte",
|
||||
"enterRecoveryKeyHint": "Saisissez votre clé de récupération",
|
||||
"recover": "Restaurer",
|
||||
"contactSupportViaEmailMessage": "Veuillez envoyer un e-mail à {} depuis votre adresse enregistrée",
|
||||
"contactSupportViaEmailMessage": "Veuillez envoyer un e-mail à {email} depuis votre adresse enregistrée",
|
||||
"@contactSupportViaEmailMessage": {
|
||||
"placeholders": {
|
||||
"email": {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"@@locale": "en",
|
||||
"@@locale": "it",
|
||||
"counterAppBarTitle": "Contatore",
|
||||
"@counterAppBarTitle": {
|
||||
"description": "Text shown in the AppBar of the Counter Page"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"@@locale": "en",
|
||||
"@@locale": "nl",
|
||||
"counterAppBarTitle": "Teller",
|
||||
"@counterAppBarTitle": {
|
||||
"description": "Text shown in the AppBar of the Counter Page"
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
{
|
||||
"@@locale": "en"
|
||||
"@@locale": "pt"
|
||||
}
|
|
@ -1,3 +1,3 @@
|
|||
{
|
||||
"@@locale": "en"
|
||||
"@@locale": "zh"
|
||||
}
|
|
@ -67,7 +67,15 @@ class Code {
|
|||
|
||||
static String _getAccount(Uri uri) {
|
||||
try {
|
||||
final String path = Uri.decodeComponent(uri.path);
|
||||
String path = Uri.decodeComponent(uri.path);
|
||||
if (path.startsWith("/")) {
|
||||
path = path.substring(1, path.length);
|
||||
}
|
||||
// Parse account name from documented auth URI
|
||||
// otpauth://totp/ACCOUNT?secret=SUPERSECRET&issuer=SERVICE
|
||||
if (uri.queryParameters.containsKey("issuer") && !path.contains(":")) {
|
||||
return path;
|
||||
}
|
||||
return path.split(':')[1];
|
||||
} catch (e) {
|
||||
return "";
|
||||
|
@ -77,7 +85,13 @@ class Code {
|
|||
static String _getIssuer(Uri uri) {
|
||||
try {
|
||||
if (uri.queryParameters.containsKey("issuer")) {
|
||||
return uri.queryParameters['issuer']!;
|
||||
String issuerName = uri.queryParameters['issuer']!;
|
||||
// Handle issuer name with period
|
||||
// See https://github.com/ente-io/auth/pull/77
|
||||
if (issuerName.contains("period=")) {
|
||||
return issuerName.substring(0, issuerName.indexOf("period="));
|
||||
}
|
||||
return issuerName;
|
||||
}
|
||||
final String path = Uri.decodeComponent(uri.path);
|
||||
return path.split(':')[0].substring(1);
|
||||
|
|
|
@ -6,8 +6,17 @@ void main() {
|
|||
final code1 = Code.fromRawData(
|
||||
"otpauth://totp/example%20finance%3Aee%40ff.gg?secret=ASKZNWOU6SVYAMVS",
|
||||
);
|
||||
expect(code1.issuer, "example finance");
|
||||
expect(code1.account, "ee@ff.gg");
|
||||
expect(code1.issuer, "example finance", reason: "issuerMismatch");
|
||||
expect(code1.account, "ee@ff.gg", reason: "accountMismatch");
|
||||
expect(code1.secret, "ASKZNWOU6SVYAMVS");
|
||||
});
|
||||
|
||||
test("parseDocumentedFormat", () {
|
||||
final code = Code.fromRawData(
|
||||
"otpauth://totp/testdata@ente.io?secret=ASKZNWOU6SVYAMVS&issuer=GitHub",
|
||||
);
|
||||
expect(code.issuer, "GitHub", reason: "issuerMismatch");
|
||||
expect(code.account, "testdata@ente.io", reason: "accountMismatch");
|
||||
expect(code.secret, "ASKZNWOU6SVYAMVS");
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue