Skip to content

Commit

Permalink
Implemented #198 (#199)
Browse files Browse the repository at this point in the history
  • Loading branch information
akopachov committed Sep 12, 2023
1 parent 5089857 commit 890e0b4
Show file tree
Hide file tree
Showing 72 changed files with 1,074 additions and 959 deletions.
29 changes: 24 additions & 5 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ $build_commands = @(
Name = "Official Dev";
FbtSwitch = "od";
FirmwarePath = "flipperzero-firmware_official_dev";
ArtifactName = "totp_official-dev_fw{FEATURES_SUFFIX}.fap";
ArtifactName = "totp_official-dev_fw{FEATURES_SUFFIX}.zip";
}
[PSCustomObject]@{
Name = "Official Stable";
FbtSwitch = "os";
FirmwarePath = "flipperzero-firmware_official_stable";
ArtifactName = "totp_official-stable_fw{FEATURES_SUFFIX}.fap";
ArtifactName = "totp_official-stable_fw{FEATURES_SUFFIX}.zip";
}
[PSCustomObject]@{
Name = "Xtreme \ Unleashed";
FbtSwitch = "x";
FirmwarePath = "flipperzero-firmware_xtreme";
ArtifactName = "totp_xtreme_unleashed_fw{FEATURES_SUFFIX}.fap";
ArtifactName = "totp_xtreme_unleashed_fw{FEATURES_SUFFIX}.zip";
}
)

Expand Down Expand Up @@ -71,7 +71,26 @@ function Build-Run {

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

Copy-Item "$build_path/$latest_dir/.extapps/totp.fap" -Destination $build_output_artifact
$zip_folder = Join-Path $build_output_folder ".zip"
if (!(Test-Path -PathType Container $zip_folder)) {
New-Item -ItemType Directory -Path $zip_folder
} elseif (!$doNotClearBuildFolder) {
Remove-Item "$zip_folder/*" -Recurse -Force
}

$zip_app_folder = Join-Path $zip_folder "apps/Tools"
New-Item $zip_app_folder -ItemType Directory -Force

Copy-Item "$build_path/$latest_dir/.extapps/totp.fap" -Destination $zip_app_folder

$zip_plugins_folder = Join-Path $zip_folder "apps_data/totp/plugins"
New-Item $zip_plugins_folder -ItemType Directory -Force

Copy-Item "$build_path/$latest_dir/.extapps/*.fal" -Destination $zip_plugins_folder

Compress-Archive -Path "$zip_folder/*" -DestinationPath $build_output_artifact

Remove-Item $zip_folder -Recurse -Force

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

$checksum_file = 'build/checksums.sha256'
New-Item $checksum_file -ItemType File -Force
Get-ChildItem -Path 'build/*.fap' | ForEach-Object {
Get-ChildItem -Path 'build/*.zip' | ForEach-Object {
$checksum = (Get-FileHash $_ -Algorithm SHA256).Hash.ToLower()
$filename = $_.Name
"$checksum $filename" >> $checksum_file
Expand Down
2 changes: 1 addition & 1 deletion flipperzero-firmware_official_dev
Submodule flipperzero-firmware_official_dev updated 81 files
+1 −2 applications/services/gui/elements.c
+28 −0 applications/system/hid_app/application.fam
+ applications/system/hid_app/assets/Alt_11x7.png
+ applications/system/hid_app/assets/Arr_dwn_7x9.png
+ applications/system/hid_app/assets/Arr_up_7x9.png
+ applications/system/hid_app/assets/Ble_connected_15x15.png
+ applications/system/hid_app/assets/Ble_disconnected_15x15.png
+ applications/system/hid_app/assets/ButtonDown_7x4.png
+ applications/system/hid_app/assets/ButtonF10_5x8.png
+ applications/system/hid_app/assets/ButtonF11_5x8.png
+ applications/system/hid_app/assets/ButtonF12_5x8.png
+ applications/system/hid_app/assets/ButtonF1_5x8.png
+ applications/system/hid_app/assets/ButtonF2_5x8.png
+ applications/system/hid_app/assets/ButtonF3_5x8.png
+ applications/system/hid_app/assets/ButtonF4_5x8.png
+ applications/system/hid_app/assets/ButtonF5_5x8.png
+ applications/system/hid_app/assets/ButtonF6_5x8.png
+ applications/system/hid_app/assets/ButtonF7_5x8.png
+ applications/system/hid_app/assets/ButtonF8_5x8.png
+ applications/system/hid_app/assets/ButtonF9_5x8.png
+ applications/system/hid_app/assets/ButtonLeft_4x7.png
+ applications/system/hid_app/assets/ButtonRight_4x7.png
+ applications/system/hid_app/assets/ButtonUp_7x4.png
+ applications/system/hid_app/assets/Button_18x18.png
+ applications/system/hid_app/assets/Circles_47x47.png
+ applications/system/hid_app/assets/Cmd_15x7.png
+ applications/system/hid_app/assets/Ctrl_15x7.png
+ applications/system/hid_app/assets/Del_12x7.png
+ applications/system/hid_app/assets/Esc_14x7.png
+ applications/system/hid_app/assets/Left_mouse_icon_9x9.png
+ applications/system/hid_app/assets/Like_def_11x9.png
+ applications/system/hid_app/assets/Like_pressed_17x17.png
+ applications/system/hid_app/assets/Ok_btn_9x9.png
+ applications/system/hid_app/assets/Ok_btn_pressed_13x13.png
+ applications/system/hid_app/assets/Pin_arrow_down_7x9.png
+ applications/system/hid_app/assets/Pin_arrow_left_9x7.png
+ applications/system/hid_app/assets/Pin_arrow_right_9x7.png
+ applications/system/hid_app/assets/Pin_arrow_up_7x9.png
+ applications/system/hid_app/assets/Pin_back_arrow_10x8.png
+ applications/system/hid_app/assets/Pressed_Button_13x13.png
+ applications/system/hid_app/assets/Right_mouse_icon_9x9.png
+ applications/system/hid_app/assets/Space_60x18.png
+ applications/system/hid_app/assets/Space_65x18.png
+ applications/system/hid_app/assets/Tab_15x7.png
+ applications/system/hid_app/assets/Voldwn_6x6.png
+ applications/system/hid_app/assets/Volup_8x6.png
+452 −0 applications/system/hid_app/hid.c
+67 −0 applications/system/hid_app/hid.h
+ applications/system/hid_app/hid_ble_10px.png
+ applications/system/hid_app/hid_usb_10px.png
+11 −0 applications/system/hid_app/views.h
+411 −0 applications/system/hid_app/views/hid_keyboard.c
+14 −0 applications/system/hid_app/views/hid_keyboard.h
+312 −0 applications/system/hid_app/views/hid_keynote.c
+16 −0 applications/system/hid_app/views/hid_keynote.h
+218 −0 applications/system/hid_app/views/hid_media.c
+13 −0 applications/system/hid_app/views/hid_media.h
+226 −0 applications/system/hid_app/views/hid_mouse.c
+17 −0 applications/system/hid_app/views/hid_mouse.h
+214 −0 applications/system/hid_app/views/hid_mouse_clicker.c
+14 −0 applications/system/hid_app/views/hid_mouse_clicker.h
+159 −0 applications/system/hid_app/views/hid_mouse_jiggler.c
+17 −0 applications/system/hid_app/views/hid_mouse_jiggler.h
+241 −0 applications/system/hid_app/views/hid_tiktok.c
+14 −0 applications/system/hid_app/views/hid_tiktok.h
+13 −0 applications/system/snake_game/application.fam
+ applications/system/snake_game/snake_10px.png
+434 −0 applications/system/snake_game/snake_game.c
+0 −110 assets/resources/infrared/assets/tv.ir
+3 −2 firmware/targets/f18/api_symbols.csv
+9 −8 firmware/targets/f18/furi_hal/furi_hal_resources.c
+3 −2 firmware/targets/f7/api_symbols.csv
+9 −8 firmware/targets/f7/furi_hal/furi_hal_resources.c
+13 −2 lib/flipper_application/application_manifest.c
+18 −7 lib/flipper_application/application_manifest.h
+10 −4 lib/flipper_application/flipper_application.c
+2 −1 lib/flipper_application/flipper_application.h
+1 −1 lib/u8g2/u8g2_glue.c
+4 −1 scripts/flipper/utils/fff.py
+79 −0 scripts/infrared.py
+2 −1 scripts/ob.py
13 changes: 13 additions & 0 deletions totp/app_api_interface.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#pragma once

#include <flipper_application/api_hashtable/api_hashtable.h>

/*
* Resolver interface with private application's symbols.
* Implementation is contained in app_api_table.c
*/
#ifdef __cplusplus
extern "C" const ElfApiInterface* const application_api_interface;
#else
extern const ElfApiInterface* const application_api_interface;
#endif
19 changes: 19 additions & 0 deletions totp/app_api_table.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include <flipper_application/api_hashtable/api_hashtable.h>
#include <flipper_application/api_hashtable/compilesort.hpp>
#include "app_api_interface.h"
#include "app_api_table_i.h"

static_assert(!has_hash_collisions(app_api_table), "Detected API method hash collision!");

constexpr HashtableApiInterface applicaton_hashtable_api_interface{
{
.api_version_major = 0,
.api_version_minor = 0,
.resolver_callback = &elf_resolve_from_hashtable,
},
.table_cbegin = app_api_table.cbegin(),
.table_cend = app_api_table.cend(),
};

extern "C" const ElfApiInterface* const application_api_interface =
&applicaton_hashtable_api_interface;
65 changes: 65 additions & 0 deletions totp/app_api_table_i.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#include <stdbool.h>
#include <cli/cli.h>
#include <lib/print/wrappers.h>
#include <lib/toolbox/args.h>
#include <memset_s.h>
#include "services/crypto/crypto_facade.h"
#include "ui/scene_director.h"
#include "services/config/config.h"
#include "cli/cli_helpers.h"
#include "workers/bt_type_code/bt_type_code.h"

static constexpr auto app_api_table = sort(create_array_t<sym_entry>(
API_METHOD(memset_s, errno_t, (void*, rsize_t, int, rsize_t)),
API_METHOD(totp_scene_director_activate_scene, void, (PluginState* const, Scene)),
API_METHOD(totp_scene_director_force_redraw, void, (PluginState* const)),
API_METHOD(totp_config_file_update_timezone_offset, bool, (const PluginState*)),
API_METHOD(totp_config_file_reset, void, (PluginState* const)),
API_METHOD(
totp_config_get_token_iterator_context,
TokenInfoIteratorContext*,
(const PluginState*)),
API_METHOD(totp_config_file_backup, char*, (const PluginState*)),
API_METHOD(
totp_config_file_update_encryption,
bool,
(PluginState*, uint8_t, const uint8_t*, uint8_t)),
API_METHOD(totp_config_file_update_automation_method, bool, (const PluginState*)),
API_METHOD(totp_config_file_update_notification_method, bool, (const PluginState*)),
API_METHOD(totp_token_info_iterator_get_total_count, size_t, (const TokenInfoIteratorContext*)),
API_METHOD(
totp_token_info_iterator_get_current_token_index,
size_t,
(const TokenInfoIteratorContext*)),
API_METHOD(totp_token_info_iterator_go_to, bool, (TokenInfoIteratorContext*, size_t)),
API_METHOD(
totp_token_info_iterator_get_current_token,
const TokenInfo*,
(const TokenInfoIteratorContext*)),
API_METHOD(
totp_token_info_iterator_add_new_token,
TotpIteratorUpdateTokenResult,
(TokenInfoIteratorContext*, TOTP_ITERATOR_UPDATE_TOKEN_ACTION, const void*)),
API_METHOD(
totp_token_info_iterator_update_current_token,
TotpIteratorUpdateTokenResult,
(TokenInfoIteratorContext*, TOTP_ITERATOR_UPDATE_TOKEN_ACTION, const void*)),
API_METHOD(
totp_token_info_iterator_move_current_token_info,
bool,
(TokenInfoIteratorContext*, size_t)),
API_METHOD(
totp_token_info_iterator_remove_current_token_info,
bool,
(TokenInfoIteratorContext*)),
API_METHOD(token_info_get_algo_as_cstr, const char*, (const TokenInfo*)),
API_METHOD(token_info_set_algo_from_str, bool, (TokenInfo*, const FuriString*)),
API_METHOD(token_info_set_digits_from_int, bool, (TokenInfo*, uint8_t)),
API_METHOD(token_info_set_duration_from_int, bool, (TokenInfo*, uint8_t)),
API_METHOD(token_info_set_automation_feature_from_str, bool, (TokenInfo*, const FuriString*)),
API_METHOD(
token_info_set_secret,
bool,
(TokenInfo*, const char*, size_t, PlainTokenSecretEncoding, const CryptoSettings*)),
API_METHOD(totp_crypto_check_key_slot, bool, (uint8_t)),
API_METHOD(totp_bt_type_code_worker_free, void, (TotpBtTypeCodeWorkerContext*))));
133 changes: 133 additions & 0 deletions totp/application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ App(
fap_category="Tools",
fap_icon_assets="images",
fap_icon="totp_10px.png",
fap_file_assets="assets",
fap_private_libs=[
Lib(
name="base32",
Expand Down Expand Up @@ -57,3 +58,135 @@ App(
),
],
)

App(
appid="totp_cli_timezone_plugin",
apptype=FlipperAppType.PLUGIN,
entry_point="totp_cli_timezone_plugin_ep",
requires=["totp"],
sources=[
"cli/plugins/timezone/timezone.c",
"cli/cli_shared_methods.c"],
)

App(
appid="totp_cli_version_plugin",
apptype=FlipperAppType.PLUGIN,
entry_point="totp_cli_version_plugin_ep",
requires=["totp"],
sources=["cli/plugins/version/version.c"],
)

App(
appid="totp_cli_help_plugin",
apptype=FlipperAppType.PLUGIN,
entry_point="totp_cli_help_plugin_ep",
requires=["totp"],
sources=["cli/plugins/help/help.c"],
)

App(
appid="totp_cli_list_plugin",
apptype=FlipperAppType.PLUGIN,
entry_point="totp_cli_list_plugin_ep",
requires=["totp"],
sources=[
"cli/plugins/list/list.c",
"cli/cli_shared_methods.c",
"cli/plugins/list/formatters/table/list_output_formatter_table.c",
"cli/plugins/list/formatters/tsv/list_output_formatter_tsv.c"],
)

App(
appid="totp_cli_details_plugin",
apptype=FlipperAppType.PLUGIN,
entry_point="totp_cli_details_plugin_ep",
requires=["totp"],
sources=[
"cli/plugins/details/details.c",
"cli/cli_shared_methods.c",
"cli/plugins/details/formatters/table/details_output_formatter_table.c",
"cli/plugins/details/formatters/tsv/details_output_formatter_tsv.c"],
)

App(
appid="totp_cli_add_plugin",
apptype=FlipperAppType.PLUGIN,
entry_point="totp_cli_add_plugin_ep",
requires=["totp"],
sources=[
"cli/plugins/modify/add/add.c",
"cli/plugins/modify/common.c",
"cli/cli_shared_methods.c"],
)

App(
appid="totp_cli_update_plugin",
apptype=FlipperAppType.PLUGIN,
entry_point="totp_cli_update_plugin_ep",
requires=["totp"],
sources=[
"cli/plugins/modify/update/update.c",
"cli/plugins/modify/common.c",
"cli/cli_shared_methods.c"],
)

App(
appid="totp_cli_delete_plugin",
apptype=FlipperAppType.PLUGIN,
entry_point="totp_cli_delete_plugin_ep",
requires=["totp"],
sources=[
"cli/plugins/delete/delete.c",
"cli/cli_shared_methods.c"],
)

App(
appid="totp_cli_move_plugin",
apptype=FlipperAppType.PLUGIN,
entry_point="totp_cli_move_plugin_ep",
requires=["totp"],
sources=[
"cli/plugins/move/move.c",
"cli/cli_shared_methods.c"],
)

App(
appid="totp_cli_reset_plugin",
apptype=FlipperAppType.PLUGIN,
entry_point="totp_cli_reset_plugin_ep",
requires=["totp"],
sources=[
"cli/plugins/reset/reset.c",
"cli/cli_shared_methods.c"],
)

App(
appid="totp_cli_pin_plugin",
apptype=FlipperAppType.PLUGIN,
entry_point="totp_cli_pin_plugin_ep",
requires=["totp"],
sources=[
"cli/plugins/pin/pin.c",
"cli/cli_shared_methods.c"],
)

App(
appid="totp_cli_automation_plugin",
apptype=FlipperAppType.PLUGIN,
entry_point="totp_cli_automation_plugin_ep",
requires=["totp"],
sources=[
"cli/plugins/automation/automation.c",
"cli/cli_shared_methods.c"],
)

App(
appid="totp_cli_notification_plugin",
apptype=FlipperAppType.PLUGIN,
entry_point="totp_cli_notification_plugin_ep",
requires=["totp"],
sources=[
"cli/plugins/notification/notification.c",
"cli/cli_shared_methods.c"],
)
55 changes: 55 additions & 0 deletions totp/assets/cli/cli_help.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
Usage:
totp (help | h | ?)
totp version
totp (list | ls)
totp (lsattr | cat) <index>
totp (add | mk | new) <name> [-a <algo>] [-e <encoding>] [-d <digits>] [-l <duration>] [-u] [-b <feature>]...
totp (update) <index> [-a <algo>] [-e <encoding>] [-n <name>] [-d <digits>] [-l <duration>] [-u] [-s] [-b <feature>]...
totp (delete | rm) <index> [-f]
totp (move | mv) <index> <new_index>
totp pin (set | remove) [-c <slot>]
totp notify [<notification>...]
totp (timezone | tz) [<timezone>]
totp reset
totp automation [-k <layout>] [<automation>...]

Commands:
help, h, ? Show command usage help
version Get application version
list, ls List all available tokens
lsattr, cat Displays token details
add, mk, new Add new token
update Update existing token
delete, rm Delete existing token
move, mv Move token
pin Set\change\remove PIN
notify Get or set notification method
timezone, tz Get or set current timezone
reset Reset application to default settings
automation Get or set automation settings

Arguments:
name Token name
index Token index in the list
new_index New token index in the list
notification Notification method to be set. Must be one of: none, sound, vibro
timezone Timezone offset in hours to be set
automation Automation method to be set. Must be one of: none, usb, bt

Options:
-a <algo> Token hashing algorithm. Must be one of: sha1, sha256, sha512, steam [default: sha1]
-d <digits> Number of digits to generate, one of: 5, 6, 8 [default: 6]
-e <encoding> Token secret encoding, one of base32, base64 [default: base32]
-l <duration> Token lifetime duration in seconds, between: 15 and 255 [default: 30]
-u Show console user input as-is without masking
-b <feature> Token automation features to be enabled. Must be one of: none, enter, tab [default: none]
# none - No features
# enter - Type <Enter> key at the end of token input automation
# tab - Type <Tab> key at the end of token input automation
# slower - Type slower
-n <name> Token name
-s Update token secret
-f Force command to do not ask user for interactive confirmation
-c <slot> New crypto key slot. Must be between 12 and 100
-k <layout> Automation keyboard layout. Must be one of: QWERTY, AZERTY, QWERTZ

Loading

0 comments on commit 890e0b4

Please sign in to comment.