MX 1 год назад
Родитель
Сommit
3ea7c57a41

+ 1 - 1
application.fam

@@ -7,7 +7,7 @@ App(
     requires=["gui", "cli", "dialogs", "storage", "input", "notification", "bt"],
     requires=["gui", "cli", "dialogs", "storage", "input", "notification", "bt"],
     stack_size=2 * 1024,
     stack_size=2 * 1024,
     order=20,
     order=20,
-    fap_version="5.150",
+    fap_version="5.160",
     fap_author="Alexander Kopachov (@akopachov)",
     fap_author="Alexander Kopachov (@akopachov)",
     fap_description="Software-based TOTP/HOTP authenticator for Flipper Zero device",
     fap_description="Software-based TOTP/HOTP authenticator for Flipper Zero device",
     fap_weburl="https://github.com/akopachov/flipper-zero_authenticator",
     fap_weburl="https://github.com/akopachov/flipper-zero_authenticator",

+ 21 - 9
cli/plugins/export/export.c

@@ -1,4 +1,6 @@
 #include <lib/toolbox/args.h>
 #include <lib/toolbox/args.h>
+#include <dialogs/dialogs.h>
+#include "../../../ui/constants.h"
 #include <flipper_application/flipper_application.h>
 #include <flipper_application/flipper_application.h>
 #include "../../../lib/polyfills/memset_s.h"
 #include "../../../lib/polyfills/memset_s.h"
 #include "../../../services/config/config.h"
 #include "../../../services/config/config.h"
@@ -57,19 +59,29 @@ static void handle(PluginState* plugin_state, FuriString* args, Cli* cli) {
     TOTP_CLI_PRINTF_WARNING("WARNING!\r\n");
     TOTP_CLI_PRINTF_WARNING("WARNING!\r\n");
     TOTP_CLI_PRINTF_WARNING(
     TOTP_CLI_PRINTF_WARNING(
         "ALL THE INFORMATION (INCL. UNENCRYPTED SECRET) ABOUT ALL THE TOKENS WILL BE EXPORTED AND PRINTED TO THE CONSOLE.\r\n");
         "ALL THE INFORMATION (INCL. UNENCRYPTED SECRET) ABOUT ALL THE TOKENS WILL BE EXPORTED AND PRINTED TO THE CONSOLE.\r\n");
-    TOTP_CLI_PRINTF_WARNING("Confirm? [y/n]\r\n");
-    fflush(stdout);
-    char user_pick;
-    do {
-        user_pick = tolower(cli_getc(cli));
-    } while(user_pick != 'y' && user_pick != 'n' && user_pick != CliSymbolAsciiCR &&
-            user_pick != CliSymbolAsciiETX && user_pick != CliSymbolAsciiEsc);
-
-    if(user_pick != 'y' && user_pick != CliSymbolAsciiCR) {
+    TOTP_CLI_PRINTF_WARNING("Confirm this action on your Flipper\r\n");
+
+    DialogMessage* message = dialog_message_alloc();
+    dialog_message_set_buttons(message, "No", NULL, "Yes");
+    dialog_message_set_text(
+        message,
+        "Would you like to\nEXPORT TOKENS AND\nUNENCRYPTED SECRETS?",
+        SCREEN_WIDTH_CENTER,
+        SCREEN_HEIGHT_CENTER - 8,
+        AlignCenter,
+        AlignCenter);
+    DialogMessageButton dialog_result = dialog_message_show(plugin_state->dialogs_app, message);
+    dialog_message_free(message);
+
+    if(dialog_result != DialogMessageButtonRight) {
         TOTP_CLI_PRINTF_INFO("User has not confirmed\r\n");
         TOTP_CLI_PRINTF_INFO("User has not confirmed\r\n");
         return;
         return;
     }
     }
 
 
+    if(!totp_cli_ensure_authenticated(plugin_state, cli)) {
+        return;
+    }
+
     TokenInfoIteratorContext* iterator_context =
     TokenInfoIteratorContext* iterator_context =
         totp_config_get_token_iterator_context(plugin_state);
         totp_config_get_token_iterator_context(plugin_state);
     size_t total_count = totp_token_info_iterator_get_total_count(iterator_context);
     size_t total_count = totp_token_info_iterator_get_total_count(iterator_context);

+ 8 - 4
services/config/config.c

@@ -773,15 +773,19 @@ bool totp_config_file_ensure_latest_encryption(
     uint8_t pin_length) {
     uint8_t pin_length) {
     bool result = true;
     bool result = true;
     if(plugin_state->crypto_settings.crypto_version < CRYPTO_LATEST_VERSION) {
     if(plugin_state->crypto_settings.crypto_version < CRYPTO_LATEST_VERSION) {
-        FURI_LOG_I(LOGGING_TAG, "Migration crypto from v%" PRIu8 " to v%" PRIu8 " is needed", plugin_state->crypto_settings.crypto_version, CRYPTO_LATEST_VERSION);
-        
+        FURI_LOG_I(
+            LOGGING_TAG,
+            "Migration crypto from v%" PRIu8 " to v%" PRIu8 " is needed",
+            plugin_state->crypto_settings.crypto_version,
+            CRYPTO_LATEST_VERSION);
+
 #ifndef TOTP_OBSOLETE_CRYPTO_V1_COMPATIBILITY_ENABLED
 #ifndef TOTP_OBSOLETE_CRYPTO_V1_COMPATIBILITY_ENABLED
-        if (plugin_state->crypto_settings.crypto_version == 1) {
+        if(plugin_state->crypto_settings.crypto_version == 1) {
             furi_crash("Authenticator: Crypto v1 is not supported");
             furi_crash("Authenticator: Crypto v1 is not supported");
         }
         }
 #endif
 #endif
 #ifndef TOTP_OBSOLETE_CRYPTO_V2_COMPATIBILITY_ENABLED
 #ifndef TOTP_OBSOLETE_CRYPTO_V2_COMPATIBILITY_ENABLED
-        if (plugin_state->crypto_settings.crypto_version == 2) {
+        if(plugin_state->crypto_settings.crypto_version == 2) {
             furi_crash("Authenticator: Crypto v2 is not supported");
             furi_crash("Authenticator: Crypto v2 is not supported");
         }
         }
 #endif
 #endif

+ 1 - 1
services/idle_timeout/idle_timeout.c

@@ -3,7 +3,7 @@
 #include <furi/core/timer.h>
 #include <furi/core/timer.h>
 
 
 #define IDLE_TIMER_CHECK_PERIODICITY_SEC (1)
 #define IDLE_TIMER_CHECK_PERIODICITY_SEC (1)
-#define SEC_TO_TICKS(sec) ((sec)*1000)
+#define SEC_TO_TICKS(sec) ((sec) * 1000)
 
 
 struct IdleTimeoutContext {
 struct IdleTimeoutContext {
     FuriTimer* timer;
     FuriTimer* timer;

+ 2 - 2
types/token_info.c

@@ -8,8 +8,8 @@
 #include "common.h"
 #include "common.h"
 #include "../services/crypto/crypto_facade.h"
 #include "../services/crypto/crypto_facade.h"
 
 
-#define ESTIMATE_BASE32_PLAIN_LENGTH(base32_length) ((base32_length)*0.625f)
-#define ESTIMATE_BASE64_PLAIN_LENGTH(base64_length) ((base64_length)*0.75f)
+#define ESTIMATE_BASE32_PLAIN_LENGTH(base32_length) ((base32_length) * 0.625f)
+#define ESTIMATE_BASE64_PLAIN_LENGTH(base64_length) ((base64_length) * 0.75f)
 
 
 TokenInfo* token_info_alloc() {
 TokenInfo* token_info_alloc() {
     TokenInfo* tokenInfo = malloc(sizeof(TokenInfo));
     TokenInfo* tokenInfo = malloc(sizeof(TokenInfo));

+ 1 - 1
version.h

@@ -1,5 +1,5 @@
 #pragma once
 #pragma once
 
 
 #define TOTP_APP_VERSION_MAJOR (5)
 #define TOTP_APP_VERSION_MAJOR (5)
-#define TOTP_APP_VERSION_MINOR (15)
+#define TOTP_APP_VERSION_MINOR (16)
 #define TOTP_APP_VERSION_PATCH (0)
 #define TOTP_APP_VERSION_PATCH (0)

+ 1 - 1
workers/bt_type_code/bt_type_code.c

@@ -14,7 +14,7 @@
 #include "../../config/app/config.h"
 #include "../../config/app/config.h"
 #include "../../services/config/constants.h"
 #include "../../services/config/constants.h"
 
 
-#define HID_BT_KEYS_STORAGE_PATH_FORMAT CONFIG_FILE_DIRECTORY_PATH "/.bt_hid_%2X.keys"
+#define HID_BT_KEYS_STORAGE_PATH_FORMAT CONFIG_FILE_DIRECTORY_PATH "/.bt_hid_%02x.keys"
 
 
 struct TotpBtTypeCodeWorkerContext {
 struct TotpBtTypeCodeWorkerContext {
     char* code_buffer;
     char* code_buffer;