OTPRunner 0.2.0__tar.gz → 0.2.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. otprunner-0.2.1/.pre-commit-config.yaml +15 -0
  2. {otprunner-0.2.0 → otprunner-0.2.1}/CHANGELOG.md +6 -0
  3. otprunner-0.2.1/CONTRIBUTING.md +110 -0
  4. {otprunner-0.2.0 → otprunner-0.2.1}/PKG-INFO +27 -1
  5. {otprunner-0.2.0 → otprunner-0.2.1}/README.md +23 -0
  6. {otprunner-0.2.0 → otprunner-0.2.1}/docs/design.md +1 -0
  7. otprunner-0.2.1/packaging/kde-store/README +33 -0
  8. otprunner-0.2.1/packaging/kde-store/install.sh +72 -0
  9. otprunner-0.2.1/packaging/kde-store/uninstall.sh +39 -0
  10. {otprunner-0.2.0 → otprunner-0.2.1}/pyproject.toml +16 -1
  11. otprunner-0.2.1/scripts/check-commits.py +43 -0
  12. otprunner-0.2.1/scripts/kde-store.sh +12 -0
  13. {otprunner-0.2.0 → otprunner-0.2.1}/scripts/migration-dump.py +8 -5
  14. {otprunner-0.2.0 → otprunner-0.2.1}/src/otprunner/__init__.py +1 -1
  15. {otprunner-0.2.0 → otprunner-0.2.1}/src/otprunner/adding.py +19 -6
  16. {otprunner-0.2.0 → otprunner-0.2.1}/src/otprunner/camera.py +16 -8
  17. {otprunner-0.2.0 → otprunner-0.2.1}/src/otprunner/capture.py +26 -13
  18. {otprunner-0.2.0 → otprunner-0.2.1}/src/otprunner/cli.py +28 -9
  19. {otprunner-0.2.0 → otprunner-0.2.1}/src/otprunner/clipboard.py +7 -4
  20. {otprunner-0.2.0 → otprunner-0.2.1}/src/otprunner/config.py +6 -2
  21. {otprunner-0.2.0 → otprunner-0.2.1}/src/otprunner/dbusutil.py +4 -3
  22. {otprunner-0.2.0 → otprunner-0.2.1}/src/otprunner/dialogs.py +31 -8
  23. {otprunner-0.2.0 → otprunner-0.2.1}/src/otprunner/doctor.py +4 -1
  24. {otprunner-0.2.0 → otprunner-0.2.1}/src/otprunner/exporting.py +10 -6
  25. {otprunner-0.2.0 → otprunner-0.2.1}/src/otprunner/notify.py +12 -5
  26. {otprunner-0.2.0 → otprunner-0.2.1}/src/otprunner/otpauth.py +2 -1
  27. {otprunner-0.2.0 → otprunner-0.2.1}/src/otprunner/runner.py +146 -66
  28. {otprunner-0.2.0 → otprunner-0.2.1}/src/otprunner/store/__init__.py +5 -3
  29. {otprunner-0.2.0 → otprunner-0.2.1}/src/otprunner/store/kwallet.py +4 -2
  30. {otprunner-0.2.0 → otprunner-0.2.1}/src/otprunner/store/secretservice.py +16 -10
  31. {otprunner-0.2.0 → otprunner-0.2.1}/tests/test_exporting.py +5 -3
  32. {otprunner-0.2.0 → otprunner-0.2.1}/tests/test_i18n.py +18 -11
  33. {otprunner-0.2.0 → otprunner-0.2.1}/tests/test_install.py +0 -1
  34. otprunner-0.2.1/tests/test_kde_store.py +67 -0
  35. {otprunner-0.2.0 → otprunner-0.2.1}/tests/test_migration.py +17 -4
  36. {otprunner-0.2.0 → otprunner-0.2.1}/tests/test_otpauth.py +4 -4
  37. {otprunner-0.2.0 → otprunner-0.2.1}/tests/test_runner.py +8 -4
  38. {otprunner-0.2.0 → otprunner-0.2.1}/tests/test_store.py +2 -1
  39. otprunner-0.2.0/CONTRIBUTING.md +0 -53
  40. {otprunner-0.2.0 → otprunner-0.2.1}/.gitignore +0 -0
  41. {otprunner-0.2.0 → otprunner-0.2.1}/LICENSE +0 -0
  42. {otprunner-0.2.0 → otprunner-0.2.1}/docs/usage.md +0 -0
  43. {otprunner-0.2.0 → otprunner-0.2.1}/scripts/i18n.sh +0 -0
  44. {otprunner-0.2.0 → otprunner-0.2.1}/src/otprunner/__main__.py +0 -0
  45. {otprunner-0.2.0 → otprunner-0.2.1}/src/otprunner/data/otprunner-small.svg +0 -0
  46. {otprunner-0.2.0 → otprunner-0.2.1}/src/otprunner/data/otprunner.svg +0 -0
  47. {otprunner-0.2.0 → otprunner-0.2.1}/src/otprunner/demo.py +0 -0
  48. {otprunner-0.2.0 → otprunner-0.2.1}/src/otprunner/i18n.py +0 -0
  49. {otprunner-0.2.0 → otprunner-0.2.1}/src/otprunner/importer.py +1 -1
  50. {otprunner-0.2.0 → otprunner-0.2.1}/src/otprunner/install.py +0 -0
  51. {otprunner-0.2.0 → otprunner-0.2.1}/src/otprunner/locale/es/LC_MESSAGES/otprunner.mo +0 -0
  52. {otprunner-0.2.0 → otprunner-0.2.1}/src/otprunner/locale/es/LC_MESSAGES/otprunner.po +0 -0
  53. {otprunner-0.2.0 → otprunner-0.2.1}/src/otprunner/locale/otprunner.pot +0 -0
  54. {otprunner-0.2.0 → otprunner-0.2.1}/src/otprunner/migration.py +1 -1
  55. {otprunner-0.2.0 → otprunner-0.2.1}/src/otprunner/store/base.py +1 -1
  56. {otprunner-0.2.0 → otprunner-0.2.1}/src/otprunner/store/memory.py +0 -0
  57. {otprunner-0.2.0 → otprunner-0.2.1}/tests/conftest.py +0 -0
  58. {otprunner-0.2.0 → otprunner-0.2.1}/tests/test_adding.py +0 -0
  59. {otprunner-0.2.0 → otprunner-0.2.1}/tests/test_camera.py +0 -0
@@ -0,0 +1,15 @@
1
+ # pre-commit install --hook-type pre-commit --hook-type commit-msg
2
+ repos:
3
+ - repo: https://github.com/astral-sh/ruff-pre-commit
4
+ rev: v0.17.6
5
+ hooks:
6
+ - id: ruff-check
7
+ args: [--fix]
8
+ - id: ruff-format
9
+ - repo: local
10
+ hooks:
11
+ - id: conventional-commit
12
+ name: conventional commit message
13
+ entry: scripts/check-commits.py
14
+ language: script
15
+ stages: [commit-msg]
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.1 (2026-11-25)
4
+
5
+ - Python 3.10: keep zxing-cpp below 3.2, which has no wheels for it and fails to build.
6
+ - KDE Store showcase entry (`packaging/kde-store/`, built with `scripts/kde-store.sh`): it
7
+ installs nothing and explains how to install OTPRunner with pipx.
8
+
3
9
  ## 0.2.0 (2026-11-24)
4
10
 
5
11
  First public release, rewritten from a personal script.
@@ -0,0 +1,110 @@
1
+ # Contributing
2
+
3
+ Bug reports, translations and pull requests are welcome. If you fork OTPRunner to change
4
+ something, consider sending the change back here so everyone gets it.
5
+
6
+ ## Development
7
+
8
+ ```bash
9
+ git clone https://github.com/baquilla/otprunner && cd otprunner
10
+ uv venv && uv pip install -e '.[dev]' # or: python -m venv .venv && .venv/bin/pip install -e '.[dev]'
11
+ pre-commit install --hook-type pre-commit --hook-type commit-msg
12
+ pytest
13
+ ```
14
+
15
+ The hooks run `ruff check --fix`, `ruff format` and the commit message check on every commit;
16
+ CI runs the same checks plus the tests on Python 3.10 to 3.14.
17
+
18
+ To try your working copy in KRunner, install it in editable mode and register it:
19
+
20
+ ```bash
21
+ pipx install -e . --force
22
+ otprunner install
23
+ ```
24
+
25
+ To watch the runner while you use KRunner: `systemctl --user stop otprunner` and run
26
+ `otprunner serve -v` in a terminal. `otprunner serve --demo` does the same with made-up
27
+ accounts, which is handy for screenshots.
28
+
29
+ ## Layout
30
+
31
+ | Module | Role |
32
+ |---|---|
33
+ | `runner.py` | KRunner DBus service: matches and actions |
34
+ | `cli.py` | Command line |
35
+ | `otpauth.py`, `migration.py` | `otpauth://` accounts and codes; Google `otpauth-migration://` codec |
36
+ | `importer.py`, `adding.py` | Parsing links, adding and updating accounts |
37
+ | `store/` | Keystore backends (KWallet, Secret Service, in-memory for tests) |
38
+ | `capture.py`, `camera.py`, `clipboard.py`, `dialogs.py`, `notify.py` | Desktop integration, each trying the available tools in order |
39
+ | `install.py`, `doctor.py` | Installation and diagnostics |
40
+
41
+ ## Translations
42
+
43
+ gettext, with English as the source language; catalogs are in `src/otprunner/locale/`.
44
+
45
+ ```bash
46
+ scripts/i18n.sh update # after changing strings: extract and update the .po files
47
+ scripts/i18n.sh init fr # start a new language
48
+ scripts/i18n.sh compile # build the .mo files (they are shipped in the package)
49
+ ```
50
+
51
+ The tests fail if a string is left untranslated or a `.mo` file is out of date.
52
+
53
+ ## Code style
54
+
55
+ - [Ruff](https://docs.astral.sh/ruff/) for linting and formatting (configuration in
56
+ `pyproject.toml`, 120 columns). `ruff check --fix && ruff format` before committing, or let
57
+ the pre-commit hook do it.
58
+ - New code, comments and docstrings in English. (Older modules still have Spanish comments;
59
+ they are being translated.)
60
+ - User-visible strings go through `_()` (or `ngettext()` / `N_()`), in English.
61
+
62
+ ## Commits
63
+
64
+ [Conventional Commits](https://www.conventionalcommits.org/), in English, imperative mood,
65
+ summary up to 100 characters:
66
+
67
+ ```
68
+ <type>(<scope>): <summary>
69
+
70
+ feat(runner): offer YubiKey codes next to keystore accounts
71
+ fix(export): keep the QR window inside short screens
72
+ docs: describe the YubiKey backend in the roadmap
73
+ ```
74
+
75
+ - **Types:** `feat`, `fix`, `docs`, `style`, `refactor`, `perf`, `test`, `build`, `ci`,
76
+ `chore`, `revert`. Add `!` after the type/scope for breaking changes.
77
+ - **Scopes** (optional): `runner`, `cli`, `store`, `kwallet`, `secretservice`, `capture`,
78
+ `camera`, `clipboard`, `export`, `import`, `install`, `doctor`, `i18n`.
79
+ - One logical change per commit: keep reformatting apart from behaviour changes.
80
+ - `scripts/check-commits.py` checks messages (commit-msg hook, and CI for pushes and pull requests).
81
+
82
+ ## Pull requests
83
+
84
+ - Branch from `main`, keep the change focused and add or update its tests.
85
+ - `pytest`, `ruff check` and `ruff format --check` must pass.
86
+ - Update `CHANGELOG.md` (under a new “Unreleased” heading) and the docs when behaviour changes.
87
+
88
+ ## Releasing
89
+
90
+ 1. Set `__version__` in `src/otprunner/__init__.py` and date the `CHANGELOG.md` entry.
91
+ 2. Commit (`chore: release X.Y.Z`), tag `vX.Y.Z` and push the tag.
92
+ 3. The release workflow tests, builds, publishes to PyPI (Trusted Publishing) and creates
93
+ the GitHub release.
94
+
95
+ ### KDE Store
96
+
97
+ The KDE Store entry is only a showcase: its archive installs nothing and does not depend on
98
+ the version, so it only needs uploading again when `packaging/kde-store/` changes.
99
+
100
+ - `scripts/kde-store.sh` builds `build/kde-store/otprunner-kde-store.tar.gz`.
101
+ - `packaging/kde-store/README` is also the entry's description on the store.
102
+ - On *Install*, KRunner's plugin installer asks for confirmation (with buttons to view the
103
+ README and the script) and runs `install.sh` in a terminal: it checks Python, pipx and
104
+ OTPRunner, prints the commands and leaves a shell open. `uninstall.sh` does the same
105
+ for removal.
106
+
107
+ ## Guidelines
108
+
109
+ - Never log, print or commit secrets. Test data uses made-up secrets.
110
+ - Visible text says *OTPRunner* (use `APP_NAME`); technical identifiers stay `otprunner`.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: OTPRunner
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: TOTP codes in KRunner, with secrets in the system keystore
5
5
  Project-URL: Homepage, https://github.com/baquilla/otprunner
6
6
  Project-URL: Documentation, https://github.com/baquilla/otprunner/blob/main/docs/usage.md
@@ -30,12 +30,15 @@ Requires-Dist: dbus-fast>=2.0
30
30
  Requires-Dist: pillow>=10
31
31
  Requires-Dist: segno>=1.6
32
32
  Requires-Dist: tomli>=2; python_version < '3.11'
33
+ Requires-Dist: zxing-cpp<3.2; python_version < '3.11'
33
34
  Requires-Dist: zxing-cpp>=2.2
34
35
  Provides-Extra: dev
35
36
  Requires-Dist: babel>=2.14; extra == 'dev'
36
37
  Requires-Dist: build>=1; extra == 'dev'
38
+ Requires-Dist: pre-commit>=4; extra == 'dev'
37
39
  Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
38
40
  Requires-Dist: pytest>=8; extra == 'dev'
41
+ Requires-Dist: ruff>=0.17; extra == 'dev'
39
42
  Requires-Dist: twine>=5; extra == 'dev'
40
43
  Description-Content-Type: text/markdown
41
44
 
@@ -113,6 +116,29 @@ welcome.
113
116
 
114
117
  The interface is available in English and Spanish; new translations are welcome.
115
118
 
119
+ ## Roadmap
120
+
121
+ Ideas and planned work; discussion and help welcome in the
122
+ [issues](https://github.com/baquilla/otprunner/issues).
123
+
124
+ - [x] **KDE Store** for Plasma 5: a [showcase entry](https://www.opendesktop.org/p/2382645/),
125
+ so OTPRunner can be found from KRunner's settings (*Get New Plugins*). It installs
126
+ nothing: its *Install* button opens a terminal with the pipx instructions
127
+ ([packaging/kde-store](https://github.com/baquilla/otprunner/tree/main/packaging/kde-store)).
128
+ - [ ] **KDE Store** for Plasma 6, once it is tested there.
129
+ - [ ] **YubiKey as an additional store.** Keep the keystore as the default, and use any
130
+ YubiKey that is plugged in alongside it:
131
+ - when adding an account, choose where it goes: keystore (default) or a YubiKey;
132
+ - when searching, show the YubiKey's codes next to the keystore ones (touch-protected
133
+ credentials ask for a touch);
134
+ - secrets on a YubiKey cannot be read back, so those accounts cannot be exported.
135
+ - [ ] **Plasma 6 and Wayland**: test on Kubuntu 25.10/26.04 (kwalletd6, portals) and fix
136
+ what comes up.
137
+ - [ ] **Flathub**, so it shows up in Discover.
138
+ - [ ] **GNOME Shell** search provider.
139
+ - [ ] More translations.
140
+ - [ ] Translate the remaining Spanish code comments to English.
141
+
116
142
  ## License
117
143
 
118
144
  [GPL-3.0-or-later](https://github.com/baquilla/otprunner/blob/main/LICENSE). Forks are
@@ -72,6 +72,29 @@ welcome.
72
72
 
73
73
  The interface is available in English and Spanish; new translations are welcome.
74
74
 
75
+ ## Roadmap
76
+
77
+ Ideas and planned work; discussion and help welcome in the
78
+ [issues](https://github.com/baquilla/otprunner/issues).
79
+
80
+ - [x] **KDE Store** for Plasma 5: a [showcase entry](https://www.opendesktop.org/p/2382645/),
81
+ so OTPRunner can be found from KRunner's settings (*Get New Plugins*). It installs
82
+ nothing: its *Install* button opens a terminal with the pipx instructions
83
+ ([packaging/kde-store](https://github.com/baquilla/otprunner/tree/main/packaging/kde-store)).
84
+ - [ ] **KDE Store** for Plasma 6, once it is tested there.
85
+ - [ ] **YubiKey as an additional store.** Keep the keystore as the default, and use any
86
+ YubiKey that is plugged in alongside it:
87
+ - when adding an account, choose where it goes: keystore (default) or a YubiKey;
88
+ - when searching, show the YubiKey's codes next to the keystore ones (touch-protected
89
+ credentials ask for a touch);
90
+ - secrets on a YubiKey cannot be read back, so those accounts cannot be exported.
91
+ - [ ] **Plasma 6 and Wayland**: test on Kubuntu 25.10/26.04 (kwalletd6, portals) and fix
92
+ what comes up.
93
+ - [ ] **Flathub**, so it shows up in Discover.
94
+ - [ ] **GNOME Shell** search provider.
95
+ - [ ] More translations.
96
+ - [ ] Translate the remaining Spanish code comments to English.
97
+
75
98
  ## License
76
99
 
77
100
  [GPL-3.0-or-later](https://github.com/baquilla/otprunner/blob/main/LICENSE). Forks are
@@ -109,6 +109,7 @@ The first language in the list that is English or has a catalog wins, so
109
109
  | Project | Difference |
110
110
  |---|---|
111
111
  | yubikey-oath-krunner | Codes from a YubiKey |
112
+ | [ente-auth-krunner](https://github.com/Bricks666/ente-auth-krunner) | Reads the codes of the Ente Auth desktop app (Plasma 6, TOTP only) |
112
113
  | [krunner-pass](https://github.com/akermu/krunner-pass) | Needs `pass` and GPG (TOTP through pass-otp) |
113
114
  | KeePassXC's KRunner integration | Needs KeePassXC; TOTP is a secondary action |
114
115
  | OTPClient, Keysmith, GNOME Authenticator | Desktop apps with their own window |
@@ -0,0 +1,33 @@
1
+ OTPRunner: your two-factor codes, one keystroke away
2
+ ====================================================
3
+
4
+ TOTP codes in KRunner, with the secrets kept in your system keystore (KWallet or the
5
+ Secret Service). Type "otp git", press Enter, and the code is in your clipboard.
6
+
7
+ - Add accounts straight from KRunner: select the QR code on screen, paste it, or show it
8
+ to the webcam.
9
+ - Import and export otpauth:// links and Google Authenticator transfer codes, including QR
10
+ codes to move your accounts to your phone.
11
+ - A full command line tool too.
12
+
13
+ HOW TO INSTALL
14
+ --------------
15
+
16
+ Do not use the Install button: this entry does not install anything. If you press it, a
17
+ terminal opens with these same instructions and nothing else is done.
18
+
19
+ OTPRunner is installed from PyPI with pipx:
20
+
21
+ sudo apt install pipx # Debian/Ubuntu; use your distribution's package otherwise
22
+ pipx install OTPRunner
23
+ otprunner install # registers the KRunner plugin and the user service
24
+
25
+ Then open KRunner and type "otp add".
26
+
27
+ To remove it: "otprunner uninstall", then "pipx uninstall otprunner". Your secrets stay in
28
+ the keystore.
29
+
30
+ Tested daily on Plasma 5.27 with X11.
31
+
32
+ Source, screenshots and documentation: https://github.com/baquilla/otprunner
33
+ License: GPL-3.0-or-later
@@ -0,0 +1,72 @@
1
+ #!/bin/sh
2
+ # OTPRunner entry in the KDE Store (Plasma 5).
3
+ #
4
+ # This script installs nothing. KRunner's "Get New Plugins" runs it in a terminal; it checks
5
+ # what is already there and shows the commands to install OTPRunner with pipx, then leaves a
6
+ # shell open so the user can run them. Source: https://github.com/baquilla/otprunner
7
+ set -u
8
+
9
+ case "${LANGUAGE:-${LC_ALL:-${LC_MESSAGES:-${LANG:-}}}}" in
10
+ es*) es=1 ;;
11
+ *) es= ;;
12
+ esac
13
+
14
+ # say "English" "Español"
15
+ say() { if [ -n "$es" ]; then printf '%s\n' "$2"; else printf '%s\n' "$1"; fi; }
16
+ check() { if [ "$1" -eq 0 ]; then printf ' ✓ %s\n' "$2"; else printf ' ✗ %s\n' "$2"; fi; }
17
+
18
+ export PATH="$HOME/.local/bin:$PATH" # where pipx puts its commands
19
+
20
+ python3 -c 'import sys; sys.exit(sys.version_info < (3, 10))' 2>/dev/null
21
+ has_python=$?
22
+ command -v pipx >/dev/null 2>&1
23
+ has_pipx=$?
24
+ command -v otprunner >/dev/null 2>&1
25
+ has_otprunner=$?
26
+ test -f "${XDG_DATA_HOME:-$HOME/.local/share}/krunner/dbusplugins/otprunner.desktop"
27
+ registered=$?
28
+
29
+ echo
30
+ say "OTPRunner: TOTP codes in KRunner" "OTPRunner: códigos TOTP en KRunner"
31
+ echo
32
+ say "This KDE Store entry does not install anything. OTPRunner is installed from PyPI" \
33
+ "Esta entrada de la KDE Store no instala nada. OTPRunner se instala desde PyPI"
34
+ say "with pipx, by running the commands below yourself." \
35
+ "con pipx, ejecutando tú mismo los comandos de abajo."
36
+ echo
37
+ check $has_python "Python ≥ 3.10"
38
+ check $has_pipx "pipx"
39
+ check $has_otprunner "OTPRunner"
40
+ check $registered "$(say "KRunner plugin registered" "complemento de KRunner registrado")"
41
+ echo
42
+
43
+ if [ $has_otprunner -eq 0 ] && [ $registered -eq 0 ]; then
44
+ say "OTPRunner is already installed. To update it:" "OTPRunner ya está instalado. Para actualizarlo:"
45
+ echo
46
+ echo " pipx upgrade otprunner"
47
+ else
48
+ say "To install it:" "Para instalarlo:"
49
+ echo
50
+ if [ $has_python -ne 0 ] || [ $has_pipx -ne 0 ]; then
51
+ echo " sudo apt install python3 pipx # Debian, Ubuntu, Kubuntu"
52
+ echo " sudo dnf install pipx # Fedora"
53
+ echo " sudo zypper install python3-pipx # openSUSE"
54
+ echo " sudo pacman -S python-pipx # Arch"
55
+ fi
56
+ [ $has_otprunner -eq 0 ] || echo " pipx install OTPRunner"
57
+ echo " otprunner install"
58
+ echo
59
+ say "Then open KRunner and type: otp add" "Después abre KRunner y escribe: otp add"
60
+ fi
61
+ echo
62
+ say "More information: https://github.com/baquilla/otprunner" \
63
+ "Más información: https://github.com/baquilla/otprunner"
64
+ echo
65
+
66
+ if [ -t 0 ] && [ -t 1 ]; then
67
+ say "A shell is open below to run them; close this window when you are done." \
68
+ "Abajo tienes una consola para ejecutarlos; cierra esta ventana cuando acabes."
69
+ echo
70
+ cd "$HOME" || exit 0
71
+ exec "${SHELL:-/bin/sh}" -i
72
+ fi
@@ -0,0 +1,39 @@
1
+ #!/bin/sh
2
+ # OTPRunner entry in the KDE Store (Plasma 5).
3
+ #
4
+ # The entry installed nothing, so there is nothing to remove here. This script shows how to
5
+ # remove OTPRunner itself, and leaves a shell open to do it.
6
+ set -u
7
+
8
+ case "${LANGUAGE:-${LC_ALL:-${LC_MESSAGES:-${LANG:-}}}}" in
9
+ es*) es=1 ;;
10
+ *) es= ;;
11
+ esac
12
+
13
+ say() { if [ -n "$es" ]; then printf '%s\n' "$2"; else printf '%s\n' "$1"; fi; }
14
+
15
+ export PATH="$HOME/.local/bin:$PATH"
16
+
17
+ echo
18
+ say "This KDE Store entry installed nothing, so there is nothing else to remove." \
19
+ "Esta entrada de la KDE Store no instaló nada, así que no hay nada más que quitar."
20
+ echo
21
+ if command -v otprunner >/dev/null 2>&1; then
22
+ say "To remove OTPRunner itself:" "Para quitar OTPRunner:"
23
+ echo
24
+ echo " otprunner uninstall"
25
+ echo " pipx uninstall otprunner"
26
+ echo
27
+ say "Your secrets stay in the keystore." "Tus secretos se quedan en el keystore."
28
+ else
29
+ say "OTPRunner is not installed." "OTPRunner no está instalado."
30
+ fi
31
+ echo
32
+
33
+ if [ -t 0 ] && [ -t 1 ] && command -v otprunner >/dev/null 2>&1; then
34
+ say "A shell is open below; close this window when you are done." \
35
+ "Abajo tienes una consola; cierra esta ventana cuando acabes."
36
+ echo
37
+ cd "$HOME" || exit 0
38
+ exec "${SHELL:-/bin/sh}" -i
39
+ fi
@@ -34,6 +34,8 @@ dependencies = [
34
34
  "tomli>=2; python_version<'3.11'",
35
35
  "segno>=1.6", # generación de QR (export)
36
36
  "zxing-cpp>=2.2", # lectura de QR desde imagen
37
+ # 3.2.0 has no wheels for Python 3.10 and its sdist does not build.
38
+ "zxing-cpp<3.2; python_version<'3.11'",
37
39
  "pillow>=10",
38
40
  ]
39
41
 
@@ -44,7 +46,7 @@ Issues = "https://github.com/baquilla/otprunner/issues"
44
46
  Changelog = "https://github.com/baquilla/otprunner/blob/main/CHANGELOG.md"
45
47
 
46
48
  [project.optional-dependencies]
47
- dev = ["pytest>=8", "pytest-asyncio>=0.23", "babel>=2.14", "build>=1", "twine>=5"]
49
+ dev = ["pytest>=8", "pytest-asyncio>=0.23", "babel>=2.14", "build>=1", "twine>=5", "ruff>=0.17", "pre-commit>=4"]
48
50
 
49
51
  [project.scripts]
50
52
  otprunner = "otprunner.cli:main"
@@ -62,3 +64,16 @@ packages = ["src/otprunner"]
62
64
  testpaths = ["tests"]
63
65
  asyncio_mode = "auto"
64
66
  asyncio_default_fixture_loop_scope = "function"
67
+
68
+ [tool.ruff]
69
+ line-length = 120
70
+ target-version = "py310"
71
+
72
+ [tool.ruff.lint]
73
+ select = ["E", "F", "W", "I", "B", "UP", "SIM", "RUF"]
74
+ # Un if/else con dos textos traducibles se lee mejor que un ternario.
75
+ ignore = ["SIM108"]
76
+
77
+ [tool.ruff.lint.per-file-ignores]
78
+ # dbus-fast lee las firmas DBus de las anotaciones («s», «a(sss)»…), que no son tipos Python.
79
+ "src/otprunner/runner.py" = ["F722", "F821"]
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/env python3
2
+ """Check commit messages against Conventional Commits (https://www.conventionalcommits.org).
3
+
4
+ scripts/check-commits.py <file> # commit-msg hook: the message file
5
+ scripts/check-commits.py --range A..B # CI: every commit in a git range
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ import re
11
+ import subprocess
12
+ import sys
13
+
14
+ TYPES = ("feat", "fix", "docs", "style", "refactor", "perf", "test", "build", "ci", "chore", "revert")
15
+ PATTERN = re.compile(rf"^({'|'.join(TYPES)})(\([a-z0-9._-]+\))?!?: \S.{{0,98}}$")
16
+ SKIP = re.compile(r"^(Merge |Revert \"|fixup! |squash! )")
17
+
18
+
19
+ def check(subject: str) -> str | None:
20
+ if SKIP.match(subject) or PATTERN.match(subject):
21
+ return None
22
+ expected = f"<type>(<scope>)?: <summary>, type in {', '.join(TYPES)}"
23
+ return f"not a Conventional Commit: {subject!r}\n expected: {expected}"
24
+
25
+
26
+ def main(argv: list[str]) -> int:
27
+ if len(argv) == 2 and argv[0] == "--range":
28
+ out = subprocess.run(["git", "log", "--format=%s", argv[1]], capture_output=True, text=True, check=True)
29
+ subjects = [s for s in out.stdout.splitlines() if s]
30
+ elif len(argv) == 1:
31
+ with open(argv[0], encoding="utf-8") as f:
32
+ subjects = [next((line for line in f if line.strip() and not line.startswith("#")), "").rstrip("\n")]
33
+ else:
34
+ print(__doc__, file=sys.stderr)
35
+ return 2
36
+ errors = [e for e in map(check, subjects) if e]
37
+ for e in errors:
38
+ print(e, file=sys.stderr)
39
+ return 1 if errors else 0
40
+
41
+
42
+ if __name__ == "__main__":
43
+ sys.exit(main(sys.argv[1:]))
@@ -0,0 +1,12 @@
1
+ #!/bin/sh
2
+ # Builds the archive for the KDE Store entry: build/kde-store/otprunner-kde-store.tar.gz
3
+ # The entry installs nothing; see packaging/kde-store/README.
4
+ set -eu
5
+ cd "$(dirname "$0")/.."
6
+ src=packaging/kde-store
7
+ out=build/kde-store
8
+ mkdir -p "$out"
9
+ # Flat archive: KRunner's plugin installer looks for install*/uninstall* next to the files.
10
+ tar -C "$src" --owner=0 --group=0 --numeric-owner --mtime=@0 --sort=name \
11
+ -czf "$out/otprunner-kde-store.tar.gz" README install.sh uninstall.sh
12
+ echo "$out/otprunner-kde-store.tar.gz"
@@ -55,8 +55,10 @@ def fields(b: bytes):
55
55
  def dump(uri: str, names: bool) -> None:
56
56
  q = parse_qs(urlsplit(uri.strip()).query)
57
57
  raw = q["data"][0]
58
- print(f"URI: {len(uri.strip())} caracteres; data base64: {len(raw)} (padding {'sí' if raw.endswith('=') else 'no'}, "
59
- f"«+» {'sí' if '+' in raw else 'no'}, «%» en la URI {'sí' if '%' in uri else 'no'})")
58
+ print(
59
+ f"URI: {len(uri.strip())} caracteres; data base64: {len(raw)} (padding {'sí' if raw.endswith('=') else 'no'}, "
60
+ f"«+» {'sí' if '+' in raw else 'no'}, «%» en la URI {'sí' if '%' in uri else 'no'})"
61
+ )
60
62
  payload = base64.b64decode(raw + "=" * (-len(raw) % 4))
61
63
  print(f"payload: {len(payload)} bytes")
62
64
  for num, wt, v, _pos in fields(payload):
@@ -72,8 +74,9 @@ def dump(uri: str, names: bool) -> None:
72
74
  elif n2 not in OTP and wt2 == 2:
73
75
  # Campo desconocido: su estructura, por si es un mensaje anidado (sin valores).
74
76
  try:
75
- inner = ", ".join(f"[{a}] wt{b}" + (f"={c}" if b == 0 else f" {len(c)}B")
76
- for a, b, c, _ in fields(v2))
77
+ inner = ", ".join(
78
+ f"[{a}] wt{b}" + (f"={c}" if b == 0 else f" {len(c)}B") for a, b, c, _ in fields(v2)
79
+ )
77
80
  except (ValueError, IndexError):
78
81
  inner = "no es protobuf"
79
82
  print(f" [{n2}] {l2}: {len(v2)} bytes (wt {wt2}): {inner}")
@@ -91,7 +94,7 @@ def main() -> None:
91
94
  for uri in uris:
92
95
  uri = uri.strip()
93
96
  if uri.startswith("QR-Code:"):
94
- uri = uri[len("QR-Code:"):]
97
+ uri = uri[len("QR-Code:") :]
95
98
  dump(uri, names)
96
99
  print()
97
100
 
@@ -1,6 +1,6 @@
1
1
  """OTPRunner: códigos TOTP en KRunner con secretos en el keystore del sistema."""
2
2
 
3
- __version__ = "0.2.0"
3
+ __version__ = "0.2.1"
4
4
 
5
5
  # Nombre de producto para todo lo visible (notificaciones, diálogos, KRunner).
6
6
  # Los identificadores técnicos (comando, paquete, DBus, ficheros) van en minúsculas.
@@ -2,9 +2,8 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- from dataclasses import dataclass, field
6
-
7
5
  from collections.abc import Callable
6
+ from dataclasses import dataclass, field
8
7
 
9
8
  from . import camera, capture, importer
10
9
  from .dbusutil import name_available
@@ -62,8 +61,14 @@ class Outcome:
62
61
  return title, "\n".join(lines)
63
62
 
64
63
 
65
- async def acquire(source: str, bus, *, uri: str | None = None, device: str | None = None,
66
- progress: Callable[[str], None] | None = None) -> tuple[importer.Parsed, list[str]]:
64
+ async def acquire(
65
+ source: str,
66
+ bus,
67
+ *,
68
+ uri: str | None = None,
69
+ device: str | None = None,
70
+ progress: Callable[[str], None] | None = None,
71
+ ) -> tuple[importer.Parsed, list[str]]:
67
72
  """Devuelve las cuentas encontradas y avisos para el usuario."""
68
73
  if source == "uri":
69
74
  return importer.parse_text(uri or ""), []
@@ -87,8 +92,16 @@ async def acquire(source: str, bus, *, uri: str | None = None, device: str | Non
87
92
  raise ValueError(f"unknown source: {source}")
88
93
 
89
94
 
90
- async def add(store: Store, source: str, bus, *, name: str | None = None, uri: str | None = None,
91
- device: str | None = None, progress: Callable[[str], None] | None = None) -> Outcome:
95
+ async def add(
96
+ store: Store,
97
+ source: str,
98
+ bus,
99
+ *,
100
+ name: str | None = None,
101
+ uri: str | None = None,
102
+ device: str | None = None,
103
+ progress: Callable[[str], None] | None = None,
104
+ ) -> Outcome:
92
105
  parsed, notes = await acquire(source, bus, uri=uri, device=device, progress=progress)
93
106
  out = Outcome(parsed, notes=notes)
94
107
  if parsed.accounts:
@@ -20,6 +20,8 @@ from .otpauth import OtpError
20
20
  log = logging.getLogger(__name__)
21
21
 
22
22
  SCAN_TIMEOUT = 180
23
+
24
+
23
25
  def window_title() -> str:
24
26
  return _("{app}: show the QR code to the camera (Esc or close to cancel)").format(app=APP_NAME)
25
27
 
@@ -86,8 +88,11 @@ class Collector:
86
88
  if len(got) >= b.batch_size:
87
89
  self.done = True
88
90
  else:
89
- self.progress(_("Batch {i} of {n} read ({got}/{n}): show the next QR code").format(
90
- i=b.batch_index + 1, n=b.batch_size, got=len(got)))
91
+ self.progress(
92
+ _("Batch {i} of {n} read ({got}/{n}): show the next QR code").format(
93
+ i=b.batch_index + 1, n=b.batch_size, got=len(got)
94
+ )
95
+ )
91
96
  else:
92
97
  log.info("QR code ignored: not otpauth")
93
98
  return self.done
@@ -98,8 +103,7 @@ async def _zbarcam(device: str | None, col: Collector) -> None:
98
103
  cmd = ["zbarcam", "-q", "--nodbus", "-Sdisable", "-Sqrcode.enable"]
99
104
  if device:
100
105
  cmd.append(device)
101
- proc = await asyncio.create_subprocess_exec(
102
- *cmd, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE)
106
+ proc = await asyncio.create_subprocess_exec(*cmd, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE)
103
107
  try:
104
108
  while True:
105
109
  line = await proc.stdout.readline()
@@ -123,8 +127,11 @@ async def _zbarcam(device: str | None, col: Collector) -> None:
123
127
  except asyncio.TimeoutError: # algún hijo mantiene stderr abierto
124
128
  err = ""
125
129
  if proc.returncode not in (0, None, -15) and not col.texts:
126
- raise CameraError(_("zbarcam failed ({rc}): {detail}").format(
127
- rc=proc.returncode, detail=err.splitlines()[-1] if err else _("no details")))
130
+ raise CameraError(
131
+ _("zbarcam failed ({rc}): {detail}").format(
132
+ rc=proc.returncode, detail=err.splitlines()[-1] if err else _("no details")
133
+ )
134
+ )
128
135
 
129
136
 
130
137
  def _opencv_blocking(device: str | None, col: Collector, deadline: float) -> None:
@@ -156,8 +163,9 @@ def _opencv_blocking(device: str | None, col: Collector, deadline: float) -> Non
156
163
  cv2.destroyAllWindows()
157
164
 
158
165
 
159
- async def scan(device: str | None = None, progress: Callable[[str], None] | None = None,
160
- timeout: float = SCAN_TIMEOUT) -> list[str]:
166
+ async def scan(
167
+ device: str | None = None, progress: Callable[[str], None] | None = None, timeout: float = SCAN_TIMEOUT
168
+ ) -> list[str]:
161
169
  """Devuelve los textos otpauth leídos (vacío si el usuario cerró sin leer nada)."""
162
170
  provs = providers()
163
171
  if not provs: