From d1ba52df3cd50ed072df3753eac08388a82a771f Mon Sep 17 00:00:00 2001 From: Dain Nilsson Date: Thu, 5 May 2022 12:37:21 +0200 Subject: [PATCH 1/3] Update ykman-rpc and fix set_mode. --- ykman-rpc/.flake8 => .flake8 | 0 ykman-rpc/poetry.lock | 176 +++++++++++++++++------------------ ykman-rpc/pyproject.toml | 4 +- ykman-rpc/rpc/__init__.py | 2 +- ykman-rpc/rpc/base.py | 13 +-- ykman-rpc/rpc/device.py | 22 ++--- ykman-rpc/rpc/management.py | 25 ++--- ykman-rpc/rpc/oath.py | 3 +- ykman-rpc/rpc/qr.py | 4 +- ykman-rpc/rpc/yubiotp.py | 5 +- 10 files changed, 122 insertions(+), 132 deletions(-) rename ykman-rpc/.flake8 => .flake8 (100%) diff --git a/ykman-rpc/.flake8 b/.flake8 similarity index 100% rename from ykman-rpc/.flake8 rename to .flake8 diff --git a/ykman-rpc/poetry.lock b/ykman-rpc/poetry.lock index 8b12673f..c4941866 100755 --- a/ykman-rpc/poetry.lock +++ b/ykman-rpc/poetry.lock @@ -41,7 +41,7 @@ pycparser = "*" [[package]] name = "click" -version = "8.1.2" +version = "8.1.3" description = "Composable command line interface toolkit" category = "main" optional = false @@ -60,7 +60,7 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" [[package]] name = "cryptography" -version = "36.0.2" +version = "37.0.2" description = "cryptography is a package which provides cryptographic recipes and primitives to Python developers." category = "main" optional = false @@ -75,28 +75,21 @@ docstest = ["pyenchant (>=1.6.11)", "twine (>=1.12.0)", "sphinxcontrib-spelling pep8test = ["black", "flake8", "flake8-import-order", "pep8-naming"] sdist = ["setuptools_rust (>=0.11.4)"] ssh = ["bcrypt (>=3.1.5)"] -test = ["pytest (>=6.2.0)", "pytest-cov", "pytest-subtests", "pytest-xdist", "pretend", "iso8601", "pytz", "hypothesis (>=1.11.4,!=3.79.2)"] +test = ["pytest (>=6.2.0)", "pytest-benchmark", "pytest-cov", "pytest-subtests", "pytest-xdist", "pretend", "iso8601", "pytz", "hypothesis (>=1.11.4,!=3.79.2)"] [[package]] name = "fido2" -version = "1.0.0-dev0" +version = "1.0.0rc1" description = "FIDO2/WebAuthn library for implementing clients and servers." category = "main" optional = false -python-versions = "^3.6" -develop = false +python-versions = ">=3.7,<4.0" [package.dependencies] -cryptography = ">=2.1, !=35, <39" +cryptography = ">=2.6,<35 || >35,<39" [package.extras] -pcsc = ["pyscard (>=1.9,<3.0.0)"] - -[package.source] -type = "git" -url = "https://github.com/Yubico/python-fido2.git" -reference = "fd30409" -resolved_reference = "fd30409b032a75ff879f444f4e43b2ce00a02fbe" +pcsc = ["pyscard (>=1.9,<3)"] [[package]] name = "future" @@ -270,7 +263,7 @@ hook_testing = ["pytest (>=2.7.3)", "execnet (>=1.5.0)", "psutil"] [[package]] name = "pyinstaller-hooks-contrib" -version = "2022.3" +version = "2022.4" description = "Community maintained hooks for PyInstaller" category = "dev" optional = false @@ -278,14 +271,14 @@ python-versions = ">=3.7" [[package]] name = "pyparsing" -version = "3.0.7" -description = "Python parsing module" +version = "3.0.8" +description = "pyparsing module - Classes and methods to define and execute parsing grammars" category = "dev" optional = false -python-versions = ">=3.6" +python-versions = ">=3.6.8" [package.extras] -diagrams = ["jinja2", "railroad-diagrams"] +diagrams = ["railroad-diagrams", "jinja2"] [[package]] name = "pyscard" @@ -301,7 +294,7 @@ Pyro = ["pyro"] [[package]] name = "pytest" -version = "7.1.1" +version = "7.1.2" description = "pytest: simple powerful testing with Python" category = "dev" optional = false @@ -322,7 +315,7 @@ testing = ["argcomplete", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2. [[package]] name = "pywin32" -version = "303" +version = "304" description = "Python for Window Extensions" category = "main" optional = false @@ -338,7 +331,7 @@ python-versions = "*" [[package]] name = "secretstorage" -version = "3.3.1" +version = "3.3.2" description = "Python bindings to FreeDesktop.org Secret Service API" category = "main" optional = false @@ -362,13 +355,13 @@ version = "5.0.0-dev0" description = "Tool for managing your YubiKey configuration." category = "main" optional = false -python-versions = "^3.6" +python-versions = "^3.7" develop = false [package.dependencies] click = "^6.0 || ^7.0 || ^8.0" -cryptography = ">=2.5, <39" -fido2 = ">=0.9, <2.0" +cryptography = ">=2.6, <39" +fido2 = "1.0.0rc1" keyring = "^23.4" pyscard = "^1.9 || ^2.0" pywin32 = {version = ">=223", markers = "sys_platform == \"win32\""} @@ -376,8 +369,8 @@ pywin32 = {version = ">=223", markers = "sys_platform == \"win32\""} [package.source] type = "git" url = "https://github.com/Yubico/yubikey-manager.git" -reference = "22a72b2" -resolved_reference = "22a72b23b2cb8a52001bf23b770e0045956bdeb7" +reference = "e37f5f8" +resolved_reference = "e37f5f87140795e32f38933a99140f4b07ccd6c2" [[package]] name = "zipp" @@ -393,7 +386,7 @@ testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest- [[package]] name = "zxing-cpp" -version = "1.2.0" +version = "1.3.0" description = "Python bindings for the zxing-cpp barcode library" category = "main" optional = false @@ -405,7 +398,7 @@ numpy = "*" [metadata] lock-version = "1.1" python-versions = "^3.8" -content-hash = "2b8b3413c3ad288a38aa9c3d573f895b0c4cc5435a80cc182c5c682a7258e472" +content-hash = "d9b4682af5b547e5e0bc2d2efcd6ccbb1c76115fbfdb654b8786d380a5821b77" [metadata.files] altgraph = [ @@ -473,36 +466,41 @@ cffi = [ {file = "cffi-1.15.0.tar.gz", hash = "sha256:920f0d66a896c2d99f0adbb391f990a84091179542c205fa53ce5787aff87954"}, ] click = [ - {file = "click-8.1.2-py3-none-any.whl", hash = "sha256:24e1a4a9ec5bf6299411369b208c1df2188d9eb8d916302fe6bf03faed227f1e"}, - {file = "click-8.1.2.tar.gz", hash = "sha256:479707fe14d9ec9a0757618b7a100a0ae4c4e236fac5b7f80ca68028141a1a72"}, + {file = "click-8.1.3-py3-none-any.whl", hash = "sha256:bb4d8133cb15a609f44e8213d9b391b0809795062913b383c62be0ee95b1db48"}, + {file = "click-8.1.3.tar.gz", hash = "sha256:7682dc8afb30297001674575ea00d1814d808d6a36af415a82bd481d37ba7b8e"}, ] colorama = [ {file = "colorama-0.4.4-py2.py3-none-any.whl", hash = "sha256:9f47eda37229f68eee03b24b9748937c7dc3868f906e8ba69fbcbdd3bc5dc3e2"}, {file = "colorama-0.4.4.tar.gz", hash = "sha256:5941b2b48a20143d2267e95b1c2a7603ce057ee39fd88e7329b0c292aa16869b"}, ] cryptography = [ - {file = "cryptography-36.0.2-cp36-abi3-macosx_10_10_universal2.whl", hash = "sha256:4e2dddd38a5ba733be6a025a1475a9f45e4e41139d1321f412c6b360b19070b6"}, - {file = "cryptography-36.0.2-cp36-abi3-macosx_10_10_x86_64.whl", hash = "sha256:4881d09298cd0b669bb15b9cfe6166f16fc1277b4ed0d04a22f3d6430cb30f1d"}, - {file = "cryptography-36.0.2-cp36-abi3-manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:ea634401ca02367c1567f012317502ef3437522e2fc44a3ea1844de028fa4b84"}, - {file = "cryptography-36.0.2-cp36-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_24_aarch64.whl", hash = "sha256:7be666cc4599b415f320839e36367b273db8501127b38316f3b9f22f17a0b815"}, - {file = "cryptography-36.0.2-cp36-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8241cac0aae90b82d6b5c443b853723bcc66963970c67e56e71a2609dc4b5eaf"}, - {file = "cryptography-36.0.2-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7b2d54e787a884ffc6e187262823b6feb06c338084bbe80d45166a1cb1c6c5bf"}, - {file = "cryptography-36.0.2-cp36-abi3-manylinux_2_24_x86_64.whl", hash = "sha256:c2c5250ff0d36fd58550252f54915776940e4e866f38f3a7866d92b32a654b86"}, - {file = "cryptography-36.0.2-cp36-abi3-musllinux_1_1_aarch64.whl", hash = "sha256:ec6597aa85ce03f3e507566b8bcdf9da2227ec86c4266bd5e6ab4d9e0cc8dab2"}, - {file = "cryptography-36.0.2-cp36-abi3-musllinux_1_1_x86_64.whl", hash = "sha256:ca9f686517ec2c4a4ce930207f75c00bf03d94e5063cbc00a1dc42531511b7eb"}, - {file = "cryptography-36.0.2-cp36-abi3-win32.whl", hash = "sha256:f64b232348ee82f13aac22856515ce0195837f6968aeaa94a3d0353ea2ec06a6"}, - {file = "cryptography-36.0.2-cp36-abi3-win_amd64.whl", hash = "sha256:53e0285b49fd0ab6e604f4c5d9c5ddd98de77018542e88366923f152dbeb3c29"}, - {file = "cryptography-36.0.2-pp37-pypy37_pp73-manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:32db5cc49c73f39aac27574522cecd0a4bb7384e71198bc65a0d23f901e89bb7"}, - {file = "cryptography-36.0.2-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d2b3d199647468d410994dbeb8cec5816fb74feb9368aedf300af709ef507e3e"}, - {file = "cryptography-36.0.2-pp37-pypy37_pp73-manylinux_2_24_x86_64.whl", hash = "sha256:da73d095f8590ad437cd5e9faf6628a218aa7c387e1fdf67b888b47ba56a17f0"}, - {file = "cryptography-36.0.2-pp38-pypy38_pp73-macosx_10_10_x86_64.whl", hash = "sha256:0a3bf09bb0b7a2c93ce7b98cb107e9170a90c51a0162a20af1c61c765b90e60b"}, - {file = "cryptography-36.0.2-pp38-pypy38_pp73-manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:8897b7b7ec077c819187a123174b645eb680c13df68354ed99f9b40a50898f77"}, - {file = "cryptography-36.0.2-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:82740818f2f240a5da8dfb8943b360e4f24022b093207160c77cadade47d7c85"}, - {file = "cryptography-36.0.2-pp38-pypy38_pp73-manylinux_2_24_x86_64.whl", hash = "sha256:1f64a62b3b75e4005df19d3b5235abd43fa6358d5516cfc43d87aeba8d08dd51"}, - {file = "cryptography-36.0.2-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:e167b6b710c7f7bc54e67ef593f8731e1f45aa35f8a8a7b72d6e42ec76afd4b3"}, - {file = "cryptography-36.0.2.tar.gz", hash = "sha256:70f8f4f7bb2ac9f340655cbac89d68c527af5bb4387522a8413e841e3e6628c9"}, + {file = "cryptography-37.0.2-cp36-abi3-macosx_10_10_universal2.whl", hash = "sha256:ef15c2df7656763b4ff20a9bc4381d8352e6640cfeb95c2972c38ef508e75181"}, + {file = "cryptography-37.0.2-cp36-abi3-macosx_10_10_x86_64.whl", hash = "sha256:3c81599befb4d4f3d7648ed3217e00d21a9341a9a688ecdd615ff72ffbed7336"}, + {file = "cryptography-37.0.2-cp36-abi3-manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:2bd1096476aaac820426239ab534b636c77d71af66c547b9ddcd76eb9c79e004"}, + {file = "cryptography-37.0.2-cp36-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_24_aarch64.whl", hash = "sha256:31fe38d14d2e5f787e0aecef831457da6cec68e0bb09a35835b0b44ae8b988fe"}, + {file = "cryptography-37.0.2-cp36-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:093cb351031656d3ee2f4fa1be579a8c69c754cf874206be1d4cf3b542042804"}, + {file = "cryptography-37.0.2-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:59b281eab51e1b6b6afa525af2bd93c16d49358404f814fe2c2410058623928c"}, + {file = "cryptography-37.0.2-cp36-abi3-manylinux_2_24_x86_64.whl", hash = "sha256:0cc20f655157d4cfc7bada909dc5cc228211b075ba8407c46467f63597c78178"}, + {file = "cryptography-37.0.2-cp36-abi3-musllinux_1_1_aarch64.whl", hash = "sha256:f8ec91983e638a9bcd75b39f1396e5c0dc2330cbd9ce4accefe68717e6779e0a"}, + {file = "cryptography-37.0.2-cp36-abi3-musllinux_1_1_x86_64.whl", hash = "sha256:46f4c544f6557a2fefa7ac8ac7d1b17bf9b647bd20b16decc8fbcab7117fbc15"}, + {file = "cryptography-37.0.2-cp36-abi3-win32.whl", hash = "sha256:731c8abd27693323b348518ed0e0705713a36d79fdbd969ad968fbef0979a7e0"}, + {file = "cryptography-37.0.2-cp36-abi3-win_amd64.whl", hash = "sha256:471e0d70201c069f74c837983189949aa0d24bb2d751b57e26e3761f2f782b8d"}, + {file = "cryptography-37.0.2-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a68254dd88021f24a68b613d8c51d5c5e74d735878b9e32cc0adf19d1f10aaf9"}, + {file = "cryptography-37.0.2-pp37-pypy37_pp73-manylinux_2_24_x86_64.whl", hash = "sha256:a7d5137e556cc0ea418dca6186deabe9129cee318618eb1ffecbd35bee55ddc1"}, + {file = "cryptography-37.0.2-pp38-pypy38_pp73-macosx_10_10_x86_64.whl", hash = "sha256:aeaba7b5e756ea52c8861c133c596afe93dd716cbcacae23b80bc238202dc023"}, + {file = "cryptography-37.0.2-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:95e590dd70642eb2079d280420a888190aa040ad20f19ec8c6e097e38aa29e06"}, + {file = "cryptography-37.0.2-pp38-pypy38_pp73-manylinux_2_24_x86_64.whl", hash = "sha256:1b9362d34363f2c71b7853f6251219298124aa4cc2075ae2932e64c91a3e2717"}, + {file = "cryptography-37.0.2-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:e53258e69874a306fcecb88b7534d61820db8a98655662a3dd2ec7f1afd9132f"}, + {file = "cryptography-37.0.2-pp39-pypy39_pp73-macosx_10_10_x86_64.whl", hash = "sha256:1f3bfbd611db5cb58ca82f3deb35e83af34bb8cf06043fa61500157d50a70982"}, + {file = "cryptography-37.0.2-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:419c57d7b63f5ec38b1199a9521d77d7d1754eb97827bbb773162073ccd8c8d4"}, + {file = "cryptography-37.0.2-pp39-pypy39_pp73-manylinux_2_24_x86_64.whl", hash = "sha256:dc26bb134452081859aa21d4990474ddb7e863aa39e60d1592800a8865a702de"}, + {file = "cryptography-37.0.2-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:3b8398b3d0efc420e777c40c16764d6870bcef2eb383df9c6dbb9ffe12c64452"}, + {file = "cryptography-37.0.2.tar.gz", hash = "sha256:f224ad253cc9cea7568f49077007d2263efa57396a2f2f78114066fd54b5c68e"}, +] +fido2 = [ + {file = "fido2-1.0.0rc1-py3-none-any.whl", hash = "sha256:9ae3a021b0f90ad03ab2c5da3d7ad40841052e6d39607f8f649d8c9af183089d"}, + {file = "fido2-1.0.0rc1.tar.gz", hash = "sha256:fa4180ac150ffb4eb71b1b06e08755edd2062e1ef368cfc0059f265e0e4256af"}, ] -fido2 = [] future = [ {file = "future-0.18.2.tar.gz", hash = "sha256:b1bead90b70cf6ec3f0710ae53a525360fa360d306a86583adc6bf83a4db537d"}, ] @@ -535,6 +533,7 @@ numpy = [ {file = "numpy-1.22.3-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:8251ed96f38b47b4295b1ae51631de7ffa8260b5b087808ef09a39a9d66c97ab"}, {file = "numpy-1.22.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:48a3aecd3b997bf452a2dedb11f4e79bc5bfd21a1d4cc760e703c31d57c84b3e"}, {file = "numpy-1.22.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a3bae1a2ed00e90b3ba5f7bd0a7c7999b55d609e0c54ceb2b076a25e345fa9f4"}, + {file = "numpy-1.22.3-cp310-cp310-win32.whl", hash = "sha256:f950f8845b480cffe522913d35567e29dd381b0dc7e4ce6a4a9f9156417d2430"}, {file = "numpy-1.22.3-cp310-cp310-win_amd64.whl", hash = "sha256:08d9b008d0156c70dc392bb3ab3abb6e7a711383c3247b410b39962263576cd4"}, {file = "numpy-1.22.3-cp38-cp38-macosx_10_14_x86_64.whl", hash = "sha256:201b4d0552831f7250a08d3b38de0d989d6f6e4658b709a02a73c524ccc6ffce"}, {file = "numpy-1.22.3-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:f8c1f39caad2c896bc0018f699882b345b2a63708008be29b1f355ebf6f933fe"}, @@ -624,12 +623,12 @@ pyinstaller = [ {file = "pyinstaller-4.10.tar.gz", hash = "sha256:7749c868d2e2dc84df7d6f65437226183c8a366f3a99bb2737785625c3a3cca1"}, ] pyinstaller-hooks-contrib = [ - {file = "pyinstaller-hooks-contrib-2022.3.tar.gz", hash = "sha256:9fa4ca03d058cba676c3cc16005076ce6a529f144c08b87c69998625fbd84e0a"}, - {file = "pyinstaller_hooks_contrib-2022.3-py2.py3-none-any.whl", hash = "sha256:9765e68552803327d58f6c5eca970bb245b7cdf073e2f912a2a3cb50360bc2d8"}, + {file = "pyinstaller-hooks-contrib-2022.4.tar.gz", hash = "sha256:b7f7da20e5b83c22219a21b8f849525e5f735197975313208f4e07ff9549cdaf"}, + {file = "pyinstaller_hooks_contrib-2022.4-py2.py3-none-any.whl", hash = "sha256:b57a90bb8520d6e1dbbaaae416875e28fa5a3b74d2e40e330d02d1ccadacc38c"}, ] pyparsing = [ - {file = "pyparsing-3.0.7-py3-none-any.whl", hash = "sha256:a6c06a88f252e6c322f65faf8f418b16213b51bdfaece0524c1c1bc30c63c484"}, - {file = "pyparsing-3.0.7.tar.gz", hash = "sha256:18ee9022775d270c55187733956460083db60b37d0d0fb357445f3094eed3eea"}, + {file = "pyparsing-3.0.8-py3-none-any.whl", hash = "sha256:ef7b523f6356f763771559412c0d7134753f037822dad1b16945b7b846f7ad06"}, + {file = "pyparsing-3.0.8.tar.gz", hash = "sha256:7bf433498c016c4314268d95df76c81b842a4cb2b276fa3312cfb1e1d85f6954"}, ] pyscard = [ {file = "pyscard-2.0.3-cp310-cp310-win_amd64.whl", hash = "sha256:f7748157d293f57688307f94d780c93bd3ceaf309b39b92a0af792bf1ddb82e7"}, @@ -639,30 +638,32 @@ pyscard = [ {file = "pyscard-2.0.3.tar.gz", hash = "sha256:13c3e108163fac4f1237804ed20c5b1eb1bd5d5ee3e96adb60bfb6b9122f528d"}, ] pytest = [ - {file = "pytest-7.1.1-py3-none-any.whl", hash = "sha256:92f723789a8fdd7180b6b06483874feca4c48a5c76968e03bb3e7f806a1869ea"}, - {file = "pytest-7.1.1.tar.gz", hash = "sha256:841132caef6b1ad17a9afde46dc4f6cfa59a05f9555aae5151f73bdf2820ca63"}, + {file = "pytest-7.1.2-py3-none-any.whl", hash = "sha256:13d0e3ccfc2b6e26be000cb6568c832ba67ba32e719443bfe725814d3c42433c"}, + {file = "pytest-7.1.2.tar.gz", hash = "sha256:a06a0425453864a270bc45e71f783330a7428defb4230fb5e6a731fde06ecd45"}, ] pywin32 = [ - {file = "pywin32-303-cp310-cp310-win32.whl", hash = "sha256:6fed4af057039f309263fd3285d7b8042d41507343cd5fa781d98fcc5b90e8bb"}, - {file = "pywin32-303-cp310-cp310-win_amd64.whl", hash = "sha256:51cb52c5ec6709f96c3f26e7795b0bf169ee0d8395b2c1d7eb2c029a5008ed51"}, - {file = "pywin32-303-cp311-cp311-win32.whl", hash = "sha256:d9b5d87ca944eb3aa4cd45516203ead4b37ab06b8b777c54aedc35975dec0dee"}, - {file = "pywin32-303-cp311-cp311-win_amd64.whl", hash = "sha256:fcf44032f5b14fcda86028cdf49b6ebdaea091230eb0a757282aa656e4732439"}, - {file = "pywin32-303-cp36-cp36m-win32.whl", hash = "sha256:aad484d52ec58008ca36bd4ad14a71d7dd0a99db1a4ca71072213f63bf49c7d9"}, - {file = "pywin32-303-cp36-cp36m-win_amd64.whl", hash = "sha256:2a09632916b6bb231ba49983fe989f2f625cea237219530e81a69239cd0c4559"}, - {file = "pywin32-303-cp37-cp37m-win32.whl", hash = "sha256:b1675d82bcf6dbc96363fca747bac8bff6f6e4a447a4287ac652aa4b9adc796e"}, - {file = "pywin32-303-cp37-cp37m-win_amd64.whl", hash = "sha256:c268040769b48a13367221fced6d4232ed52f044ffafeda247bd9d2c6bdc29ca"}, - {file = "pywin32-303-cp38-cp38-win32.whl", hash = "sha256:5f9ec054f5a46a0f4dfd72af2ce1372f3d5a6e4052af20b858aa7df2df7d355b"}, - {file = "pywin32-303-cp38-cp38-win_amd64.whl", hash = "sha256:793bf74fce164bcffd9d57bb13c2c15d56e43c9542a7b9687b4fccf8f8a41aba"}, - {file = "pywin32-303-cp39-cp39-win32.whl", hash = "sha256:7d3271c98434617a11921c5ccf74615794d97b079e22ed7773790822735cc352"}, - {file = "pywin32-303-cp39-cp39-win_amd64.whl", hash = "sha256:79cbb862c11b9af19bcb682891c1b91942ec2ff7de8151e2aea2e175899cda34"}, + {file = "pywin32-304-cp310-cp310-win32.whl", hash = "sha256:3c7bacf5e24298c86314f03fa20e16558a4e4138fc34615d7de4070c23e65af3"}, + {file = "pywin32-304-cp310-cp310-win_amd64.whl", hash = "sha256:4f32145913a2447736dad62495199a8e280a77a0ca662daa2332acf849f0be48"}, + {file = "pywin32-304-cp310-cp310-win_arm64.whl", hash = "sha256:d3ee45adff48e0551d1aa60d2ec066fec006083b791f5c3527c40cd8aefac71f"}, + {file = "pywin32-304-cp311-cp311-win32.whl", hash = "sha256:30c53d6ce44c12a316a06c153ea74152d3b1342610f1b99d40ba2795e5af0269"}, + {file = "pywin32-304-cp311-cp311-win_amd64.whl", hash = "sha256:7ffa0c0fa4ae4077e8b8aa73800540ef8c24530057768c3ac57c609f99a14fd4"}, + {file = "pywin32-304-cp311-cp311-win_arm64.whl", hash = "sha256:cbbe34dad39bdbaa2889a424d28752f1b4971939b14b1bb48cbf0182a3bcfc43"}, + {file = "pywin32-304-cp36-cp36m-win32.whl", hash = "sha256:be253e7b14bc601718f014d2832e4c18a5b023cbe72db826da63df76b77507a1"}, + {file = "pywin32-304-cp36-cp36m-win_amd64.whl", hash = "sha256:de9827c23321dcf43d2f288f09f3b6d772fee11e809015bdae9e69fe13213988"}, + {file = "pywin32-304-cp37-cp37m-win32.whl", hash = "sha256:f64c0377cf01b61bd5e76c25e1480ca8ab3b73f0c4add50538d332afdf8f69c5"}, + {file = "pywin32-304-cp37-cp37m-win_amd64.whl", hash = "sha256:bb2ea2aa81e96eee6a6b79d87e1d1648d3f8b87f9a64499e0b92b30d141e76df"}, + {file = "pywin32-304-cp38-cp38-win32.whl", hash = "sha256:94037b5259701988954931333aafd39cf897e990852115656b014ce72e052e96"}, + {file = "pywin32-304-cp38-cp38-win_amd64.whl", hash = "sha256:ead865a2e179b30fb717831f73cf4373401fc62fbc3455a0889a7ddac848f83e"}, + {file = "pywin32-304-cp39-cp39-win32.whl", hash = "sha256:25746d841201fd9f96b648a248f731c1dec851c9a08b8e33da8b56148e4c65cc"}, + {file = "pywin32-304-cp39-cp39-win_amd64.whl", hash = "sha256:d24a3382f013b21aa24a5cfbfad5a2cd9926610c0affde3e8ab5b3d7dbcf4ac9"}, ] pywin32-ctypes = [ {file = "pywin32-ctypes-0.2.0.tar.gz", hash = "sha256:24ffc3b341d457d48e8922352130cf2644024a4ff09762a2261fd34c36ee5942"}, {file = "pywin32_ctypes-0.2.0-py2.py3-none-any.whl", hash = "sha256:9dc2d991b3479cc2df15930958b674a48a227d5361d413827a4cfd0b5876fc98"}, ] secretstorage = [ - {file = "SecretStorage-3.3.1-py3-none-any.whl", hash = "sha256:422d82c36172d88d6a0ed5afdec956514b189ddbfb72fefab0c8a1cee4eaf71f"}, - {file = "SecretStorage-3.3.1.tar.gz", hash = "sha256:fd666c51a6bf200643495a04abb261f83229dcb6fd8472ec393df7ffc8b6f195"}, + {file = "SecretStorage-3.3.2-py3-none-any.whl", hash = "sha256:755dc845b6ad76dcbcbc07ea3da75ae54bb1ea529eb72d15f83d26499a5df319"}, + {file = "SecretStorage-3.3.2.tar.gz", hash = "sha256:0a8eb9645b320881c222e827c26f4cfcf55363e8b374a021981ef886657a912f"}, ] tomli = [ {file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"}, @@ -674,20 +675,19 @@ zipp = [ {file = "zipp-3.8.0.tar.gz", hash = "sha256:56bf8aadb83c24db6c4b577e13de374ccfb67da2078beba1d037c17980bf43ad"}, ] zxing-cpp = [ - {file = "zxing-cpp-1.2.0.tar.gz", hash = "sha256:342b71872844e1b703b04e1f5a60bf1932ff1b7389974ce9f1fc63d19ebb32b4"}, - {file = "zxing_cpp-1.2.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:3f7d0996e291c6e36030e29611e5728c3d5b426e6e839b842f305d8c3d4691d9"}, - {file = "zxing_cpp-1.2.0-cp37-cp37m-manylinux2010_i686.whl", hash = "sha256:c5668ba3ae488d1faf056bc1061112e55b0363dc196bfe9e24f995a8f91f9a84"}, - {file = "zxing_cpp-1.2.0-cp37-cp37m-manylinux2010_x86_64.whl", hash = "sha256:080c991e277efef984e1b017be166128a4c35639de75395875048825db4366d3"}, - {file = "zxing_cpp-1.2.0-cp37-cp37m-win32.whl", hash = "sha256:738216a2b96c61c43eda810a6858b81472467adddd6e712e0ead1250cfb396a2"}, - {file = "zxing_cpp-1.2.0-cp37-cp37m-win_amd64.whl", hash = "sha256:09baf7e96e871b95f2295e8383e749de9da709328f181aff3e3a82c8b044a24c"}, - {file = "zxing_cpp-1.2.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:189f8d476f5bb8a4027a681963625941671d1eecbe4d5755ba5aae61fe8d9f35"}, - {file = "zxing_cpp-1.2.0-cp38-cp38-manylinux2010_i686.whl", hash = "sha256:4024e7e9452a85e4a05e5f2c65216e46533c31964c4d77c3b4e0e28f66182b20"}, - {file = "zxing_cpp-1.2.0-cp38-cp38-manylinux2010_x86_64.whl", hash = "sha256:715911447c8a361c0ed2add860e186755651ba540ef7c947986b82bccd417dba"}, - {file = "zxing_cpp-1.2.0-cp38-cp38-win32.whl", hash = "sha256:1ac49f1e750d9383a15d93de47f8f60587561f74b3377f8aa678e2e77062e9a8"}, - {file = "zxing_cpp-1.2.0-cp38-cp38-win_amd64.whl", hash = "sha256:37b008de65808479ce8697f7b62ca24a8880322dea79bc690e8cc6f705a29e1b"}, - {file = "zxing_cpp-1.2.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:190386da493ab2fa133a83fea6964cf90ea22fa18770c3783594ed0310b91018"}, - {file = "zxing_cpp-1.2.0-cp39-cp39-manylinux2010_i686.whl", hash = "sha256:2f83363b4f96d0bd83748ed76f78f2a5452c4c5df42c74538e11d38e49bf3b13"}, - {file = "zxing_cpp-1.2.0-cp39-cp39-manylinux2010_x86_64.whl", hash = "sha256:3ee7d5208474cc81901e17a89a42258d4e6da8693d51a831bb5eb6bfa6da19fb"}, - {file = "zxing_cpp-1.2.0-cp39-cp39-win32.whl", hash = "sha256:04726ec5da54ff92b8fe8735050685722631aaef96126d068dab59d4dde6e568"}, - {file = "zxing_cpp-1.2.0-cp39-cp39-win_amd64.whl", hash = "sha256:f5929c1f950027f1eb74fd3fd2ceecd6da649b9293dc9cbbad2d3bac2214ace1"}, + {file = "zxing-cpp-1.3.0.tar.gz", hash = "sha256:5f30545afad01a278fc8c17efae11d82e36f8c2caa87c89096aec5a8d69103b2"}, + {file = "zxing_cpp-1.3.0-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:e3a6e183b6c0aae9378f674f9e7714a39482595915cf15198d10b9ba8c33b25f"}, + {file = "zxing_cpp-1.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:88eadb723d20655caf81a6ba6ef64d74a266f57cbd782da82736c52a61a73fa5"}, + {file = "zxing_cpp-1.3.0-cp310-cp310-win32.whl", hash = "sha256:15fb165ada1730ab0d96b67eb2d9827870d9ae534686e27541f3b3add15b96d7"}, + {file = "zxing_cpp-1.3.0-cp310-cp310-win_amd64.whl", hash = "sha256:8dbb17a31ee1ac2c946a96e83b170ecefbc87a52b9c35b41809d9afff77d8879"}, + {file = "zxing_cpp-1.3.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:31578db20ba0668e010cb62e4718cb86f47563ec5122e29a0746651ff1e13735"}, + {file = "zxing_cpp-1.3.0-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:9253a3b6c8c143f3c22d172922226b10c8cc319d2554c73107fefce7e263daaa"}, + {file = "zxing_cpp-1.3.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:250afd201f08bd1be8fd349766e32ef184a463b616c13102b2f80a4422695957"}, + {file = "zxing_cpp-1.3.0-cp38-cp38-win32.whl", hash = "sha256:d2891dfba5c53b913867e7b01b8b430d801e15e54f53b3c05b9645dc824dfed3"}, + {file = "zxing_cpp-1.3.0-cp38-cp38-win_amd64.whl", hash = "sha256:6201e60cbefbc8de90c5f18e6e25c3cb1be19be8f369bf4dad3ab910b954f29d"}, + {file = "zxing_cpp-1.3.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:44467984c1a65a332c8656926f30af1752c1ff774c6a030b95572e0a1543b23b"}, + {file = "zxing_cpp-1.3.0-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:0dbb54f8694063376d73be6f7dbddd39f3e7907ab885403d90cff7d518c54f7f"}, + {file = "zxing_cpp-1.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e3cff8a7fe960c2016bc8e217fcf02b9b1ac61b17fc5c0c5158f853088be4ad9"}, + {file = "zxing_cpp-1.3.0-cp39-cp39-win32.whl", hash = "sha256:f75431cf7cddcb21c267d39a5895831a3c20abfa7676426974652d25b29ae429"}, + {file = "zxing_cpp-1.3.0-cp39-cp39-win_amd64.whl", hash = "sha256:de9dd0a2d01969e9828c5704d709b2559a417fea562bd2f308ebc8d4a9678b5e"}, ] diff --git a/ykman-rpc/pyproject.toml b/ykman-rpc/pyproject.toml index 7b01f834..346adeef 100644 --- a/ykman-rpc/pyproject.toml +++ b/ykman-rpc/pyproject.toml @@ -6,8 +6,8 @@ authors = ["Dain Nilsson "] [tool.poetry.dependencies] python = "^3.8" -yubikey-manager = { git = "https://github.com/Yubico/yubikey-manager.git", rev = "22a72b2" } -fido2 = { git = "https://github.com/Yubico/python-fido2.git", rev = "fd30409" } +yubikey-manager = { git = "https://github.com/Yubico/yubikey-manager.git", rev = "e37f5f8" } +fido2 = {version = "1.0.0rc1", allow-prereleases = true} mss = "^6.1.0" zxing-cpp = "^1.2.0" Pillow = "^8|^9" diff --git a/ykman-rpc/rpc/__init__.py b/ykman-rpc/rpc/__init__.py index 894874a2..5ea00777 100644 --- a/ykman-rpc/rpc/__init__.py +++ b/ykman-rpc/rpc/__init__.py @@ -194,4 +194,4 @@ def run_rpc_socket(sock): return json.loads(line) return None - run_rpc(send, recv) \ No newline at end of file + run_rpc(send, recv) diff --git a/ykman-rpc/rpc/base.py b/ykman-rpc/rpc/base.py index a8cb6dee..89595caf 100644 --- a/ykman-rpc/rpc/base.py +++ b/ykman-rpc/rpc/base.py @@ -181,12 +181,13 @@ class RpcNode: def create_child(self, name): child = getattr(self, name, None) - options = getattr(child, MARKER_CHILD, None) - if options is not None: - condition = options["condition"] - if condition and not condition(self): - raise NoSuchNodeException(name) - return child() + if child is not None: + options = getattr(child, MARKER_CHILD, None) + if options is not None: + condition = options["condition"] + if condition and not condition(self): + raise NoSuchNodeException(name) + return child() raise NoSuchNodeException(name) def _close_child(self): diff --git a/ykman-rpc/rpc/device.py b/ykman-rpc/rpc/device.py index 1050877f..d98cb8ef 100644 --- a/ykman-rpc/rpc/device.py +++ b/ykman-rpc/rpc/device.py @@ -34,18 +34,14 @@ from .management import ManagementNode from .qr import scan_qr from ykman import __version__ as ykman_version from ykman.base import PID -from ykman.device import ( - scan_devices, - list_all_devices, - get_name, - read_info, -) +from ykman.device import scan_devices, list_all_devices from ykman.diagnostics import get_diagnostics from ykman.logging import set_log_level from yubikit.core import TRANSPORT from yubikit.core.smartcard import SmartCardConnection, ApduError, SW from yubikit.core.otp import OtpConnection from yubikit.core.fido import FidoConnection +from yubikit.support import get_name, read_info from yubikit.management import CAPABILITY from yubikit.logging import LOG_LEVEL @@ -199,7 +195,7 @@ class DevicesNode(RpcNode): else: dev_id = _id_from_fingerprint(dev.fingerprint) self._device_mapping[dev_id] = (dev, info) - name = get_name(info, dev.pid.get_type() if dev.pid else None) + name = get_name(info, dev.pid.yubikey_type if dev.pid else None) self._devices[dev_id] = dict(pid=dev.pid, name=name, serial=info.serial) if sum(state[0].values()) == len(self._devices): @@ -249,8 +245,8 @@ class AbstractDeviceNode(RpcNode): try: with self._device.open_connection(conn_type) as conn: pid = self._device.pid - self._info = read_info(pid, conn) - name = get_name(self._info, pid.get_type() if pid else None) + self._info = read_info(conn, pid) + name = get_name(self._info, pid.yubikey_type if pid else None) return dict( pid=pid, name=name, @@ -296,13 +292,13 @@ class ReaderDeviceNode(AbstractDeviceNode): @child def ccid(self): connection = self._device.open_connection(SmartCardConnection) - info = read_info(None, connection) + info = read_info(connection) return ConnectionNode(self._device, connection, info) @child def fido(self): with self._device.open_connection(SmartCardConnection) as conn: - info = read_info(None, conn) + info = read_info(conn) connection = self._device.open_connection(FidoConnection) return ConnectionNode(self._device, connection, info) @@ -313,7 +309,7 @@ class ConnectionNode(RpcNode): self._device = device self._transport = device.transport self._connection = connection - self._info = info or read_info(device.pid, self._connection) + self._info = info or read_info(self._connection, device.pid) def __call__(self, *args, **kwargs): try: @@ -342,7 +338,7 @@ class ConnectionNode(RpcNode): isinstance(self._connection, SmartCardConnection) or self._transport == TRANSPORT.USB ): - self._info = read_info(self._device.pid, self._connection) + self._info = read_info(self._connection, self._device.pid) return dict(version=self._info.version, serial=self._info.serial) @child( diff --git a/ykman-rpc/rpc/management.py b/ykman-rpc/rpc/management.py index 7ccc2868..f7708768 100644 --- a/ykman-rpc/rpc/management.py +++ b/ykman-rpc/rpc/management.py @@ -31,7 +31,7 @@ from yubikit.core import require_version, NotSupportedError, TRANSPORT from yubikit.core.smartcard import SmartCardConnection from yubikit.core.otp import OtpConnection from yubikit.core.fido import FidoConnection -from yubikit.management import ManagementSession, DeviceConfig, Mode, USB_INTERFACE +from yubikit.management import ManagementSession, DeviceConfig, Mode from ykman.device import connect_to_device from dataclasses import asdict from time import sleep @@ -62,25 +62,16 @@ class ManagementNode(RpcNode): return actions def _await_reboot(self, serial, usb_enabled): - # TODO: Clean up once "support" is merged into ykman. - iface = USB_INTERFACE.for_capabilities(usb_enabled) - connection_types = [] + ifaces = usb_enabled.usb_interfaces # Prefer to use the "same" connection type as before - if iface.supports_connection(self._connection_type): - if issubclass(self._connection_type, SmartCardConnection): - connection_types = [SmartCardConnection] - elif issubclass(self._connection_type, OtpConnection): - connection_types = [OtpConnection] - elif issubclass(self._connection_type, FidoConnection): - connection_types = [FidoConnection] - - # Allow any expected connection type - if not connection_types: + if self._connection_type.usb_interface in ifaces: + connection_types = [self._connection_type] + else: connection_types = [ t for t in [SmartCardConnection, OtpConnection, FidoConnection] - if iface.supports_connection(t) + if ifaces.supports_connection(t) ] self.session.close() @@ -117,8 +108,8 @@ class ManagementNode(RpcNode): @action def set_mode(self, params, event, signal): self.session.set_mode( - Mode.from_code(params["mode"]), + Mode(params["interfaces"]), params.pop("challenge_response_timeout", 0), - params.pop("auto_eject_timeout", 0), + params.pop("auto_eject_timeout"), ) return dict() diff --git a/ykman-rpc/rpc/oath.py b/ykman-rpc/rpc/oath.py index 2c9d8c45..32718e35 100644 --- a/ykman-rpc/rpc/oath.py +++ b/ykman-rpc/rpc/oath.py @@ -61,10 +61,11 @@ class KEYSTORE(str, Enum): class OathNode(RpcNode): _keystore_state = KEYSTORE.UNKNOWN + _oath_keys = None @classmethod def _get_keys(cls): - if not hasattr(cls, "_oath_keys"): + if not cls._oath_keys: cls._oath_keys = AppData("oath_keys") return cls._oath_keys diff --git a/ykman-rpc/rpc/qr.py b/ykman-rpc/rpc/qr.py index 301701e9..efa02511 100644 --- a/ykman-rpc/rpc/qr.py +++ b/ykman-rpc/rpc/qr.py @@ -5,8 +5,8 @@ import io from PIL import Image -def scan_qr(image_data = None): - if (image_data): +def scan_qr(image_data=None): + if image_data: msg = base64.b64decode(image_data) buf = io.BytesIO(msg) img = Image.open(buf) diff --git a/ykman-rpc/rpc/yubiotp.py b/ykman-rpc/rpc/yubiotp.py index 1ce908a0..b447c0d4 100644 --- a/ykman-rpc/rpc/yubiotp.py +++ b/ykman-rpc/rpc/yubiotp.py @@ -39,6 +39,7 @@ from yubikit.yubiotp import ( YubiOtpSlotConfiguration, StaticTicketSlotConfiguration, ) +from typing import Dict class YubiOtpNode(RpcNode): @@ -48,7 +49,7 @@ class YubiOtpNode(RpcNode): def get_data(self): state = self.session.get_config_state() - data = {} + data: Dict[str, bool] = {} try: data.update( slot1_configured=state.is_configured(SLOT.ONE), @@ -97,7 +98,7 @@ class SlotNode(RpcNode): def get_data(self): self._state = self.session.get_config_state() - data = {} + data: Dict[str, bool] = {} try: data.update(is_configured=self._state.is_configured(self.slot)) data.update(is_touch_triggered=self._state.is_touch_triggered(self.slot)) From 338d8773c346a843ff4b6eab1b10fe3cba2c6ecf Mon Sep 17 00:00:00 2001 From: Dain Nilsson Date: Thu, 5 May 2022 12:40:56 +0200 Subject: [PATCH 2/3] Implement set_mode for YK<=4. --- lib/android/management/state.dart | 6 +- lib/desktop/management/state.dart | 8 +- lib/management/state.dart | 7 +- lib/management/views/management_screen.dart | 99 +++++++++++---------- 4 files changed, 66 insertions(+), 54 deletions(-) diff --git a/lib/android/management/state.dart b/lib/android/management/state.dart index 1806039d..bd5b55fa 100755 --- a/lib/android/management/state.dart +++ b/lib/android/management/state.dart @@ -25,8 +25,10 @@ class _AndroidManagementStateNotifier extends ManagementStateNotifier { void refresh() async {} @override - Future setMode(int mode, - {int challengeResponseTimeout = 0, int autoEjectTimeout = 0}) async {} + Future setMode( + {required int interfaces, + int challengeResponseTimeout = 0, + int? autoEjectTimeout}) async {} @override Future writeConfig(DeviceConfig config, diff --git a/lib/desktop/management/state.dart b/lib/desktop/management/state.dart index 465bbfd2..821600fa 100755 --- a/lib/desktop/management/state.dart +++ b/lib/desktop/management/state.dart @@ -68,10 +68,12 @@ class _DesktopManagementStateNotifier extends ManagementStateNotifier { }); @override - Future setMode(int mode, - {int challengeResponseTimeout = 0, int autoEjectTimeout = 0}) async { + Future setMode( + {required int interfaces, + int challengeResponseTimeout = 0, + int? autoEjectTimeout}) async { await _session.command('set_mode', target: _subpath, params: { - 'mode': mode, + 'interfaces': interfaces, 'challenge_response_timeout': challengeResponseTimeout, 'auto_eject_timeout': autoEjectTimeout, }); diff --git a/lib/management/state.dart b/lib/management/state.dart index 37e66349..dab5499a 100755 --- a/lib/management/state.dart +++ b/lib/management/state.dart @@ -16,6 +16,9 @@ abstract class ManagementStateNotifier String newLockCode = '', bool reboot = false}); - Future setMode(int mode, - {int challengeResponseTimeout = 0, int autoEjectTimeout = 0}); + Future setMode({ + required int interfaces, + int challengeResponseTimeout = 0, + int? autoEjectTimeout, + }); } diff --git a/lib/management/views/management_screen.dart b/lib/management/views/management_screen.dart index fc2d9f3e..94752688 100755 --- a/lib/management/views/management_screen.dart +++ b/lib/management/views/management_screen.dart @@ -45,53 +45,25 @@ class _CapabilityForm extends StatelessWidget { } } -class _ModeForm extends StatefulWidget { - final int initialInterfaces; - final Function(int) onSubmit; - const _ModeForm(this.initialInterfaces, {required this.onSubmit, Key? key}) +class _ModeForm extends StatelessWidget { + final int interfaces; + final Function(int) onChanged; + const _ModeForm(this.interfaces, {required this.onChanged, Key? key}) : super(key: key); - @override - State createState() => _ModeFormState(); -} - -class _ModeFormState extends State<_ModeForm> { - int _enabledInterfaces = 0; - - @override - void initState() { - super.initState(); - _enabledInterfaces = widget.initialInterfaces; - } - @override Widget build(BuildContext context) { - final valid = _enabledInterfaces != 0 && - _enabledInterfaces != widget.initialInterfaces; return Column(children: [ ...UsbInterface.values.map( (iface) => CheckboxListTile( title: Text(iface.name.toUpperCase()), - value: iface.value & _enabledInterfaces != 0, + value: iface.value & interfaces != 0, onChanged: (_) { - setState(() { - _enabledInterfaces ^= iface.value; - }); + onChanged(interfaces ^ iface.value); }, ), ), - Container( - padding: const EdgeInsets.all(16.0), - alignment: Alignment.centerRight, - child: ElevatedButton( - onPressed: valid - ? () { - widget.onSubmit(_enabledInterfaces); - } - : null, - child: const Text('Apply changes'), - ), - ) + Text(interfaces == 0 ? 'At least one interface must be enabled' : ''), ]); } } @@ -156,11 +128,14 @@ class ManagementScreen extends ConsumerStatefulWidget { class _ManagementScreenState extends ConsumerState { late Map _enabled; + late int _interfaces; @override void initState() { super.initState(); _enabled = widget.deviceData.info.config.enabledCapabilities; + _interfaces = UsbInterfaces.forCapabilites( + widget.deviceData.info.config.enabledCapabilities[Transport.usb] ?? 0); } Widget _buildCapabilitiesForm( @@ -216,11 +191,29 @@ class _ManagementScreenState extends ConsumerState { Widget _buildModeForm(BuildContext context, WidgetRef ref, DeviceInfo info) => _ModeForm( - UsbInterfaces.forCapabilites( - info.config.enabledCapabilities[Transport.usb] ?? 0), - onSubmit: (enabledInterfaces) { - showMessage(context, 'Not yet implemented!'); - }); + _interfaces, + onChanged: (interfaces) { + setState(() { + _interfaces = interfaces; + }); + }, + ); + + void _submitModeForm() async { + await ref + .read(managementStateProvider(widget.deviceData.node.path).notifier) + .setMode(interfaces: _interfaces); + showMessage( + context, 'Configuration updated, remove and reinsert your YubiKey'); + } + + void _submitForm() { + if (widget.deviceData.info.version.major > 4) { + _submitCapabilitiesForm(); + } else { + _submitModeForm(); + } + } @override Widget build(BuildContext context) { @@ -229,7 +222,7 @@ class _ManagementScreenState extends ConsumerState { Navigator.of(context).popUntil((route) => route.isFirst); }); - bool changed = false; + bool canSave = false; return ResponsiveDialog( title: const Text('Toggle applications'), @@ -238,14 +231,26 @@ class _ManagementScreenState extends ConsumerState { loading: () => const AppLoadingScreen(), error: (error, _) => AppFailureScreen('$error'), data: (info) { + bool hasConfig = info.version.major > 4; // TODO: Check mode for < YK5 intead - changed = !_mapEquals( - _enabled, - info.config.enabledCapabilities, - ); + if (hasConfig) { + canSave = !_mapEquals( + _enabled, + info.config.enabledCapabilities, + ); + } else { + canSave = _interfaces != 0 && + _interfaces != + UsbInterfaces.forCapabilites(widget + .deviceData + .info + .config + .enabledCapabilities[Transport.usb] ?? + 0); + } return Column( children: [ - info.version.major > 4 + hasConfig ? _buildCapabilitiesForm(context, ref, info) : _buildModeForm(context, ref, info), ], @@ -254,7 +259,7 @@ class _ManagementScreenState extends ConsumerState { ), actions: [ TextButton( - onPressed: changed ? _submitCapabilitiesForm : null, + onPressed: canSave ? _submitForm : null, child: const Text('Save'), ), ], From 977f5099820596077657aca0e1954ea1a3011f8b Mon Sep 17 00:00:00 2001 From: Dain Nilsson Date: Fri, 6 May 2022 08:34:16 +0200 Subject: [PATCH 3/3] Add NFC support for set_mode. --- lib/desktop/management/state.dart | 1 + lib/management/views/management_screen.dart | 7 ++++++- ykman-rpc/poetry.lock | 7 +++---- ykman-rpc/pyproject.toml | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/desktop/management/state.dart b/lib/desktop/management/state.dart index 821600fa..53aee0e9 100755 --- a/lib/desktop/management/state.dart +++ b/lib/desktop/management/state.dart @@ -77,6 +77,7 @@ class _DesktopManagementStateNotifier extends ManagementStateNotifier { 'challenge_response_timeout': challengeResponseTimeout, 'auto_eject_timeout': autoEjectTimeout, }); + _ref.read(attachedDevicesProvider.notifier).refresh(); } @override diff --git a/lib/management/views/management_screen.dart b/lib/management/views/management_screen.dart index 94752688..42217743 100755 --- a/lib/management/views/management_screen.dart +++ b/lib/management/views/management_screen.dart @@ -204,7 +204,12 @@ class _ManagementScreenState extends ConsumerState { .read(managementStateProvider(widget.deviceData.node.path).notifier) .setMode(interfaces: _interfaces); showMessage( - context, 'Configuration updated, remove and reinsert your YubiKey'); + context, + widget.deviceData.node.maybeMap( + nfcReader: (_) => 'Configuration updated', + orElse: () => + 'Configuration updated, remove and reinsert your YubiKey')); + Navigator.pop(context); } void _submitForm() { diff --git a/ykman-rpc/poetry.lock b/ykman-rpc/poetry.lock index c4941866..30c9e18c 100755 --- a/ykman-rpc/poetry.lock +++ b/ykman-rpc/poetry.lock @@ -369,8 +369,8 @@ pywin32 = {version = ">=223", markers = "sys_platform == \"win32\""} [package.source] type = "git" url = "https://github.com/Yubico/yubikey-manager.git" -reference = "e37f5f8" -resolved_reference = "e37f5f87140795e32f38933a99140f4b07ccd6c2" +reference = "next" +resolved_reference = "61b902b5f61024b27f32ef88b2f95bb7630afdfb" [[package]] name = "zipp" @@ -398,7 +398,7 @@ numpy = "*" [metadata] lock-version = "1.1" python-versions = "^3.8" -content-hash = "d9b4682af5b547e5e0bc2d2efcd6ccbb1c76115fbfdb654b8786d380a5821b77" +content-hash = "04aaecbad4bcfea25ea9070c13eec47f06a2f8d7155d1a96c9dafac7780c8805" [metadata.files] altgraph = [ @@ -533,7 +533,6 @@ numpy = [ {file = "numpy-1.22.3-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:8251ed96f38b47b4295b1ae51631de7ffa8260b5b087808ef09a39a9d66c97ab"}, {file = "numpy-1.22.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:48a3aecd3b997bf452a2dedb11f4e79bc5bfd21a1d4cc760e703c31d57c84b3e"}, {file = "numpy-1.22.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a3bae1a2ed00e90b3ba5f7bd0a7c7999b55d609e0c54ceb2b076a25e345fa9f4"}, - {file = "numpy-1.22.3-cp310-cp310-win32.whl", hash = "sha256:f950f8845b480cffe522913d35567e29dd381b0dc7e4ce6a4a9f9156417d2430"}, {file = "numpy-1.22.3-cp310-cp310-win_amd64.whl", hash = "sha256:08d9b008d0156c70dc392bb3ab3abb6e7a711383c3247b410b39962263576cd4"}, {file = "numpy-1.22.3-cp38-cp38-macosx_10_14_x86_64.whl", hash = "sha256:201b4d0552831f7250a08d3b38de0d989d6f6e4658b709a02a73c524ccc6ffce"}, {file = "numpy-1.22.3-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:f8c1f39caad2c896bc0018f699882b345b2a63708008be29b1f355ebf6f933fe"}, diff --git a/ykman-rpc/pyproject.toml b/ykman-rpc/pyproject.toml index 346adeef..838550af 100644 --- a/ykman-rpc/pyproject.toml +++ b/ykman-rpc/pyproject.toml @@ -6,7 +6,7 @@ authors = ["Dain Nilsson "] [tool.poetry.dependencies] python = "^3.8" -yubikey-manager = { git = "https://github.com/Yubico/yubikey-manager.git", rev = "e37f5f8" } +yubikey-manager = { git = "https://github.com/Yubico/yubikey-manager.git", branch = "next" } fido2 = {version = "1.0.0rc1", allow-prereleases = true} mss = "^6.1.0" zxing-cpp = "^1.2.0"