@@ -76,43 +76,6 @@ static void furi_string_secure_free(FuriString* str) {
76
76
furi_string_free (str );
77
77
}
78
78
79
- static bool totp_cli_read_secret (Cli * cli , FuriString * out_str , bool mask_user_input ) {
80
- uint8_t c ;
81
- while (cli_read (cli , & c , 1 ) == 1 ) {
82
- if (c == CliSymbolAsciiEsc ) {
83
- // Some keys generating escape-sequences
84
- // We need to ignore them as we care about alpha-numerics only
85
- uint8_t c2 ;
86
- cli_read_timeout (cli , & c2 , 1 , 0 );
87
- cli_read_timeout (cli , & c2 , 1 , 0 );
88
- } else if (c == CliSymbolAsciiETX ) {
89
- TOTP_CLI_DELETE_CURRENT_LINE ();
90
- TOTP_CLI_PRINTF ("Cancelled by user\r\n" );
91
- return false;
92
- } else if ((c >= '0' && c <= '9' ) || (c >= 'a' && c <= 'z' ) || (c >= 'A' && c <= 'Z' )) {
93
- if (mask_user_input ) {
94
- putc ('*' , stdout );
95
- } else {
96
- putc (c , stdout );
97
- }
98
- fflush (stdout );
99
- furi_string_push_back (out_str , c );
100
- } else if (c == CliSymbolAsciiBackspace || c == CliSymbolAsciiDel ) {
101
- size_t out_str_size = furi_string_size (out_str );
102
- if (out_str_size > 0 ) {
103
- TOTP_CLI_DELETE_LAST_CHAR ();
104
- furi_string_left (out_str , out_str_size - 1 );
105
- }
106
- } else if (c == CliSymbolAsciiCR ) {
107
- cli_nl ();
108
- break ;
109
- }
110
- }
111
-
112
- TOTP_CLI_DELETE_LAST_LINE ();
113
- return true;
114
- }
115
-
116
79
void totp_cli_command_add_handle (PluginState * plugin_state , FuriString * args , Cli * cli ) {
117
80
FuriString * temp_str = furi_string_alloc ();
118
81
TokenInfo * token_info = token_info_alloc ();
@@ -178,13 +141,17 @@ void totp_cli_command_add_handle(PluginState* plugin_state, FuriString* args, Cl
178
141
// Reading token secret
179
142
furi_string_reset (temp_str );
180
143
TOTP_CLI_PRINTF ("Enter token secret and confirm with [ENTER]\r\n" );
181
- if (!totp_cli_read_secret (cli , temp_str , mask_user_input ) ||
144
+ if (!totp_cli_read_line (cli , temp_str , mask_user_input ) ||
182
145
!totp_cli_ensure_authenticated (plugin_state , cli )) {
146
+ TOTP_CLI_DELETE_LAST_LINE ();
147
+ TOTP_CLI_PRINTF ("Cancelled by user\r\n" );
183
148
furi_string_secure_free (temp_str );
184
149
token_info_free (token_info );
185
150
return ;
186
151
}
187
152
153
+ TOTP_CLI_DELETE_LAST_LINE ();
154
+
188
155
if (!token_info_set_secret (
189
156
token_info ,
190
157
furi_string_get_cstr (temp_str ),
0 commit comments