Skip to content

Commit 890e0b4

Browse files
authored
Implemented #198 (#199)
1 parent 5089857 commit 890e0b4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+1074
-959
lines changed

build.ps1

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@ $build_commands = @(
1515
Name = "Official Dev";
1616
FbtSwitch = "od";
1717
FirmwarePath = "flipperzero-firmware_official_dev";
18-
ArtifactName = "totp_official-dev_fw{FEATURES_SUFFIX}.fap";
18+
ArtifactName = "totp_official-dev_fw{FEATURES_SUFFIX}.zip";
1919
}
2020
[PSCustomObject]@{
2121
Name = "Official Stable";
2222
FbtSwitch = "os";
2323
FirmwarePath = "flipperzero-firmware_official_stable";
24-
ArtifactName = "totp_official-stable_fw{FEATURES_SUFFIX}.fap";
24+
ArtifactName = "totp_official-stable_fw{FEATURES_SUFFIX}.zip";
2525
}
2626
[PSCustomObject]@{
2727
Name = "Xtreme \ Unleashed";
2828
FbtSwitch = "x";
2929
FirmwarePath = "flipperzero-firmware_xtreme";
30-
ArtifactName = "totp_xtreme_unleashed_fw{FEATURES_SUFFIX}.fap";
30+
ArtifactName = "totp_xtreme_unleashed_fw{FEATURES_SUFFIX}.zip";
3131
}
3232
)
3333

@@ -71,7 +71,26 @@ function Build-Run {
7171

7272
$build_output_artifact = Join-Path $build_output_folder "$($build_command.ArtifactName -replace '{FEATURES_SUFFIX}',$FeaturesSuffix)"
7373

74-
Copy-Item "$build_path/$latest_dir/.extapps/totp.fap" -Destination $build_output_artifact
74+
$zip_folder = Join-Path $build_output_folder ".zip"
75+
if (!(Test-Path -PathType Container $zip_folder)) {
76+
New-Item -ItemType Directory -Path $zip_folder
77+
} elseif (!$doNotClearBuildFolder) {
78+
Remove-Item "$zip_folder/*" -Recurse -Force
79+
}
80+
81+
$zip_app_folder = Join-Path $zip_folder "apps/Tools"
82+
New-Item $zip_app_folder -ItemType Directory -Force
83+
84+
Copy-Item "$build_path/$latest_dir/.extapps/totp.fap" -Destination $zip_app_folder
85+
86+
$zip_plugins_folder = Join-Path $zip_folder "apps_data/totp/plugins"
87+
New-Item $zip_plugins_folder -ItemType Directory -Force
88+
89+
Copy-Item "$build_path/$latest_dir/.extapps/*.fal" -Destination $zip_plugins_folder
90+
91+
Compress-Archive -Path "$zip_folder/*" -DestinationPath $build_output_artifact
92+
93+
Remove-Item $zip_folder -Recurse -Force
7594

7695
Write-Host "Artifacts for $($build_command.Name) stored at $build_output_artifact"
7796
}
@@ -85,7 +104,7 @@ Build-Run -FeaturesSuffix '_no-badbt' -CppDefine TOTP_NO_BADBT_AUTOMATION
85104

86105
$checksum_file = 'build/checksums.sha256'
87106
New-Item $checksum_file -ItemType File -Force
88-
Get-ChildItem -Path 'build/*.fap' | ForEach-Object {
107+
Get-ChildItem -Path 'build/*.zip' | ForEach-Object {
89108
$checksum = (Get-FileHash $_ -Algorithm SHA256).Hash.ToLower()
90109
$filename = $_.Name
91110
"$checksum $filename" >> $checksum_file

flipperzero-firmware_official_dev

totp/app_api_interface.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#pragma once
2+
3+
#include <flipper_application/api_hashtable/api_hashtable.h>
4+
5+
/*
6+
* Resolver interface with private application's symbols.
7+
* Implementation is contained in app_api_table.c
8+
*/
9+
#ifdef __cplusplus
10+
extern "C" const ElfApiInterface* const application_api_interface;
11+
#else
12+
extern const ElfApiInterface* const application_api_interface;
13+
#endif

totp/app_api_table.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include <flipper_application/api_hashtable/api_hashtable.h>
2+
#include <flipper_application/api_hashtable/compilesort.hpp>
3+
#include "app_api_interface.h"
4+
#include "app_api_table_i.h"
5+
6+
static_assert(!has_hash_collisions(app_api_table), "Detected API method hash collision!");
7+
8+
constexpr HashtableApiInterface applicaton_hashtable_api_interface{
9+
{
10+
.api_version_major = 0,
11+
.api_version_minor = 0,
12+
.resolver_callback = &elf_resolve_from_hashtable,
13+
},
14+
.table_cbegin = app_api_table.cbegin(),
15+
.table_cend = app_api_table.cend(),
16+
};
17+
18+
extern "C" const ElfApiInterface* const application_api_interface =
19+
&applicaton_hashtable_api_interface;

totp/app_api_table_i.h

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#include <stdbool.h>
2+
#include <cli/cli.h>
3+
#include <lib/print/wrappers.h>
4+
#include <lib/toolbox/args.h>
5+
#include <memset_s.h>
6+
#include "services/crypto/crypto_facade.h"
7+
#include "ui/scene_director.h"
8+
#include "services/config/config.h"
9+
#include "cli/cli_helpers.h"
10+
#include "workers/bt_type_code/bt_type_code.h"
11+
12+
static constexpr auto app_api_table = sort(create_array_t<sym_entry>(
13+
API_METHOD(memset_s, errno_t, (void*, rsize_t, int, rsize_t)),
14+
API_METHOD(totp_scene_director_activate_scene, void, (PluginState* const, Scene)),
15+
API_METHOD(totp_scene_director_force_redraw, void, (PluginState* const)),
16+
API_METHOD(totp_config_file_update_timezone_offset, bool, (const PluginState*)),
17+
API_METHOD(totp_config_file_reset, void, (PluginState* const)),
18+
API_METHOD(
19+
totp_config_get_token_iterator_context,
20+
TokenInfoIteratorContext*,
21+
(const PluginState*)),
22+
API_METHOD(totp_config_file_backup, char*, (const PluginState*)),
23+
API_METHOD(
24+
totp_config_file_update_encryption,
25+
bool,
26+
(PluginState*, uint8_t, const uint8_t*, uint8_t)),
27+
API_METHOD(totp_config_file_update_automation_method, bool, (const PluginState*)),
28+
API_METHOD(totp_config_file_update_notification_method, bool, (const PluginState*)),
29+
API_METHOD(totp_token_info_iterator_get_total_count, size_t, (const TokenInfoIteratorContext*)),
30+
API_METHOD(
31+
totp_token_info_iterator_get_current_token_index,
32+
size_t,
33+
(const TokenInfoIteratorContext*)),
34+
API_METHOD(totp_token_info_iterator_go_to, bool, (TokenInfoIteratorContext*, size_t)),
35+
API_METHOD(
36+
totp_token_info_iterator_get_current_token,
37+
const TokenInfo*,
38+
(const TokenInfoIteratorContext*)),
39+
API_METHOD(
40+
totp_token_info_iterator_add_new_token,
41+
TotpIteratorUpdateTokenResult,
42+
(TokenInfoIteratorContext*, TOTP_ITERATOR_UPDATE_TOKEN_ACTION, const void*)),
43+
API_METHOD(
44+
totp_token_info_iterator_update_current_token,
45+
TotpIteratorUpdateTokenResult,
46+
(TokenInfoIteratorContext*, TOTP_ITERATOR_UPDATE_TOKEN_ACTION, const void*)),
47+
API_METHOD(
48+
totp_token_info_iterator_move_current_token_info,
49+
bool,
50+
(TokenInfoIteratorContext*, size_t)),
51+
API_METHOD(
52+
totp_token_info_iterator_remove_current_token_info,
53+
bool,
54+
(TokenInfoIteratorContext*)),
55+
API_METHOD(token_info_get_algo_as_cstr, const char*, (const TokenInfo*)),
56+
API_METHOD(token_info_set_algo_from_str, bool, (TokenInfo*, const FuriString*)),
57+
API_METHOD(token_info_set_digits_from_int, bool, (TokenInfo*, uint8_t)),
58+
API_METHOD(token_info_set_duration_from_int, bool, (TokenInfo*, uint8_t)),
59+
API_METHOD(token_info_set_automation_feature_from_str, bool, (TokenInfo*, const FuriString*)),
60+
API_METHOD(
61+
token_info_set_secret,
62+
bool,
63+
(TokenInfo*, const char*, size_t, PlainTokenSecretEncoding, const CryptoSettings*)),
64+
API_METHOD(totp_crypto_check_key_slot, bool, (uint8_t)),
65+
API_METHOD(totp_bt_type_code_worker_free, void, (TotpBtTypeCodeWorkerContext*))));

totp/application.fam

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ App(
2222
fap_category="Tools",
2323
fap_icon_assets="images",
2424
fap_icon="totp_10px.png",
25+
fap_file_assets="assets",
2526
fap_private_libs=[
2627
Lib(
2728
name="base32",
@@ -57,3 +58,135 @@ App(
5758
),
5859
],
5960
)
61+
62+
App(
63+
appid="totp_cli_timezone_plugin",
64+
apptype=FlipperAppType.PLUGIN,
65+
entry_point="totp_cli_timezone_plugin_ep",
66+
requires=["totp"],
67+
sources=[
68+
"cli/plugins/timezone/timezone.c",
69+
"cli/cli_shared_methods.c"],
70+
)
71+
72+
App(
73+
appid="totp_cli_version_plugin",
74+
apptype=FlipperAppType.PLUGIN,
75+
entry_point="totp_cli_version_plugin_ep",
76+
requires=["totp"],
77+
sources=["cli/plugins/version/version.c"],
78+
)
79+
80+
App(
81+
appid="totp_cli_help_plugin",
82+
apptype=FlipperAppType.PLUGIN,
83+
entry_point="totp_cli_help_plugin_ep",
84+
requires=["totp"],
85+
sources=["cli/plugins/help/help.c"],
86+
)
87+
88+
App(
89+
appid="totp_cli_list_plugin",
90+
apptype=FlipperAppType.PLUGIN,
91+
entry_point="totp_cli_list_plugin_ep",
92+
requires=["totp"],
93+
sources=[
94+
"cli/plugins/list/list.c",
95+
"cli/cli_shared_methods.c",
96+
"cli/plugins/list/formatters/table/list_output_formatter_table.c",
97+
"cli/plugins/list/formatters/tsv/list_output_formatter_tsv.c"],
98+
)
99+
100+
App(
101+
appid="totp_cli_details_plugin",
102+
apptype=FlipperAppType.PLUGIN,
103+
entry_point="totp_cli_details_plugin_ep",
104+
requires=["totp"],
105+
sources=[
106+
"cli/plugins/details/details.c",
107+
"cli/cli_shared_methods.c",
108+
"cli/plugins/details/formatters/table/details_output_formatter_table.c",
109+
"cli/plugins/details/formatters/tsv/details_output_formatter_tsv.c"],
110+
)
111+
112+
App(
113+
appid="totp_cli_add_plugin",
114+
apptype=FlipperAppType.PLUGIN,
115+
entry_point="totp_cli_add_plugin_ep",
116+
requires=["totp"],
117+
sources=[
118+
"cli/plugins/modify/add/add.c",
119+
"cli/plugins/modify/common.c",
120+
"cli/cli_shared_methods.c"],
121+
)
122+
123+
App(
124+
appid="totp_cli_update_plugin",
125+
apptype=FlipperAppType.PLUGIN,
126+
entry_point="totp_cli_update_plugin_ep",
127+
requires=["totp"],
128+
sources=[
129+
"cli/plugins/modify/update/update.c",
130+
"cli/plugins/modify/common.c",
131+
"cli/cli_shared_methods.c"],
132+
)
133+
134+
App(
135+
appid="totp_cli_delete_plugin",
136+
apptype=FlipperAppType.PLUGIN,
137+
entry_point="totp_cli_delete_plugin_ep",
138+
requires=["totp"],
139+
sources=[
140+
"cli/plugins/delete/delete.c",
141+
"cli/cli_shared_methods.c"],
142+
)
143+
144+
App(
145+
appid="totp_cli_move_plugin",
146+
apptype=FlipperAppType.PLUGIN,
147+
entry_point="totp_cli_move_plugin_ep",
148+
requires=["totp"],
149+
sources=[
150+
"cli/plugins/move/move.c",
151+
"cli/cli_shared_methods.c"],
152+
)
153+
154+
App(
155+
appid="totp_cli_reset_plugin",
156+
apptype=FlipperAppType.PLUGIN,
157+
entry_point="totp_cli_reset_plugin_ep",
158+
requires=["totp"],
159+
sources=[
160+
"cli/plugins/reset/reset.c",
161+
"cli/cli_shared_methods.c"],
162+
)
163+
164+
App(
165+
appid="totp_cli_pin_plugin",
166+
apptype=FlipperAppType.PLUGIN,
167+
entry_point="totp_cli_pin_plugin_ep",
168+
requires=["totp"],
169+
sources=[
170+
"cli/plugins/pin/pin.c",
171+
"cli/cli_shared_methods.c"],
172+
)
173+
174+
App(
175+
appid="totp_cli_automation_plugin",
176+
apptype=FlipperAppType.PLUGIN,
177+
entry_point="totp_cli_automation_plugin_ep",
178+
requires=["totp"],
179+
sources=[
180+
"cli/plugins/automation/automation.c",
181+
"cli/cli_shared_methods.c"],
182+
)
183+
184+
App(
185+
appid="totp_cli_notification_plugin",
186+
apptype=FlipperAppType.PLUGIN,
187+
entry_point="totp_cli_notification_plugin_ep",
188+
requires=["totp"],
189+
sources=[
190+
"cli/plugins/notification/notification.c",
191+
"cli/cli_shared_methods.c"],
192+
)

totp/assets/cli/cli_help.txt

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
Usage:
2+
totp (help | h | ?)
3+
totp version
4+
totp (list | ls)
5+
totp (lsattr | cat) <index>
6+
totp (add | mk | new) <name> [-a <algo>] [-e <encoding>] [-d <digits>] [-l <duration>] [-u] [-b <feature>]...
7+
totp (update) <index> [-a <algo>] [-e <encoding>] [-n <name>] [-d <digits>] [-l <duration>] [-u] [-s] [-b <feature>]...
8+
totp (delete | rm) <index> [-f]
9+
totp (move | mv) <index> <new_index>
10+
totp pin (set | remove) [-c <slot>]
11+
totp notify [<notification>...]
12+
totp (timezone | tz) [<timezone>]
13+
totp reset
14+
totp automation [-k <layout>] [<automation>...]
15+
16+
Commands:
17+
help, h, ? Show command usage help
18+
version Get application version
19+
list, ls List all available tokens
20+
lsattr, cat Displays token details
21+
add, mk, new Add new token
22+
update Update existing token
23+
delete, rm Delete existing token
24+
move, mv Move token
25+
pin Set\change\remove PIN
26+
notify Get or set notification method
27+
timezone, tz Get or set current timezone
28+
reset Reset application to default settings
29+
automation Get or set automation settings
30+
31+
Arguments:
32+
name Token name
33+
index Token index in the list
34+
new_index New token index in the list
35+
notification Notification method to be set. Must be one of: none, sound, vibro
36+
timezone Timezone offset in hours to be set
37+
automation Automation method to be set. Must be one of: none, usb, bt
38+
39+
Options:
40+
-a <algo> Token hashing algorithm. Must be one of: sha1, sha256, sha512, steam [default: sha1]
41+
-d <digits> Number of digits to generate, one of: 5, 6, 8 [default: 6]
42+
-e <encoding> Token secret encoding, one of base32, base64 [default: base32]
43+
-l <duration> Token lifetime duration in seconds, between: 15 and 255 [default: 30]
44+
-u Show console user input as-is without masking
45+
-b <feature> Token automation features to be enabled. Must be one of: none, enter, tab [default: none]
46+
# none - No features
47+
# enter - Type <Enter> key at the end of token input automation
48+
# tab - Type <Tab> key at the end of token input automation
49+
# slower - Type slower
50+
-n <name> Token name
51+
-s Update token secret
52+
-f Force command to do not ask user for interactive confirmation
53+
-c <slot> New crypto key slot. Must be between 12 and 100
54+
-k <layout> Automation keyboard layout. Must be one of: QWERTY, AZERTY, QWERTZ
55+

0 commit comments

Comments
 (0)