keepassxc-browser-api 0.1.0__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.
- keepassxc_browser_api-0.1.0/.github/workflows/auto-merge-dependabot.yml +32 -0
- keepassxc_browser_api-0.1.0/.github/workflows/auto-release.yml +38 -0
- keepassxc_browser_api-0.1.0/.github/workflows/lint_and_test.yml +59 -0
- keepassxc_browser_api-0.1.0/.github/workflows/pypi.yml +61 -0
- keepassxc_browser_api-0.1.0/.gitignore +207 -0
- keepassxc_browser_api-0.1.0/CLAUDE.md +74 -0
- keepassxc_browser_api-0.1.0/LICENSE +21 -0
- keepassxc_browser_api-0.1.0/PKG-INFO +117 -0
- keepassxc_browser_api-0.1.0/PROTOCOL.md +609 -0
- keepassxc_browser_api-0.1.0/README.md +103 -0
- keepassxc_browser_api-0.1.0/keepassxc_browser_api/__init__.py +23 -0
- keepassxc_browser_api-0.1.0/keepassxc_browser_api/client.py +735 -0
- keepassxc_browser_api-0.1.0/keepassxc_browser_api/config.py +101 -0
- keepassxc_browser_api-0.1.0/keepassxc_browser_api/exceptions.py +27 -0
- keepassxc_browser_api-0.1.0/keepassxc_browser_api/models.py +77 -0
- keepassxc_browser_api-0.1.0/keepassxc_browser_api.egg-info/PKG-INFO +117 -0
- keepassxc_browser_api-0.1.0/keepassxc_browser_api.egg-info/SOURCES.txt +26 -0
- keepassxc_browser_api-0.1.0/keepassxc_browser_api.egg-info/dependency_links.txt +1 -0
- keepassxc_browser_api-0.1.0/keepassxc_browser_api.egg-info/requires.txt +5 -0
- keepassxc_browser_api-0.1.0/keepassxc_browser_api.egg-info/top_level.txt +1 -0
- keepassxc_browser_api-0.1.0/pyproject.toml +30 -0
- keepassxc_browser_api-0.1.0/setup.cfg +4 -0
- keepassxc_browser_api-0.1.0/tests/conftest.py +21 -0
- keepassxc_browser_api-0.1.0/tests/test_client.py +389 -0
- keepassxc_browser_api-0.1.0/tests/test_config.py +83 -0
- keepassxc_browser_api-0.1.0/tests/test_exceptions.py +28 -0
- keepassxc_browser_api-0.1.0/tests/test_init.py +17 -0
- keepassxc_browser_api-0.1.0/tests/test_models.py +52 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
name: Auto Merge Dependabot
|
|
2
|
+
on:
|
|
3
|
+
pull_request:
|
|
4
|
+
types:
|
|
5
|
+
- opened
|
|
6
|
+
branches:
|
|
7
|
+
- main
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
pull-requests: write
|
|
11
|
+
contents: write
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
auto-merge:
|
|
15
|
+
name: Auto Merge Dependabot PR
|
|
16
|
+
runs-on: ubuntu-24.04
|
|
17
|
+
if: github.actor == 'dependabot[bot]'
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v6
|
|
20
|
+
- uses: actions/create-github-app-token@v3
|
|
21
|
+
id: generate-token
|
|
22
|
+
with:
|
|
23
|
+
app-id: ${{ secrets.APP_ID_MERGE }}
|
|
24
|
+
private-key: ${{ secrets.APP_PRIVATE_KEY_MERGE }}
|
|
25
|
+
- name: Enable Pull Request Automerge
|
|
26
|
+
run: gh pr merge --squash --auto "${{ github.event.pull_request.number }}"
|
|
27
|
+
env:
|
|
28
|
+
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
|
|
29
|
+
- name: Auto approve
|
|
30
|
+
run: gh pr review --approve "${{ github.event.pull_request.number }}"
|
|
31
|
+
env:
|
|
32
|
+
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
name: Auto Release
|
|
2
|
+
on:
|
|
3
|
+
pull_request:
|
|
4
|
+
types:
|
|
5
|
+
- closed
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
contents: read
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
auto-release:
|
|
12
|
+
if: github.event.pull_request.merged == true && github.event.pull_request.user.login == 'dependabot[bot]' && contains(github.event.pull_request.labels.*.name, 'pip')
|
|
13
|
+
|
|
14
|
+
name: Auto Release
|
|
15
|
+
runs-on: ubuntu-24.04
|
|
16
|
+
steps:
|
|
17
|
+
- name: Checkout
|
|
18
|
+
uses: actions/checkout@v6
|
|
19
|
+
with:
|
|
20
|
+
fetch-depth: 0
|
|
21
|
+
- name: Get Version
|
|
22
|
+
id: get-version
|
|
23
|
+
run: |
|
|
24
|
+
LATEST_TAG=$(curl -s "https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/latest" | jq -r '.name')
|
|
25
|
+
VERSION="${LATEST_TAG#v}"
|
|
26
|
+
IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION"
|
|
27
|
+
MINOR=$((MINOR + 1))
|
|
28
|
+
PATCH=0
|
|
29
|
+
echo "version=v${MAJOR}.${MINOR}.${PATCH}" >> $GITHUB_OUTPUT
|
|
30
|
+
- uses: actions/create-github-app-token@v3
|
|
31
|
+
id: generate-token
|
|
32
|
+
with:
|
|
33
|
+
app-id: ${{ secrets.APP_ID_MERGE }}
|
|
34
|
+
private-key: ${{ secrets.APP_PRIVATE_KEY_MERGE }}
|
|
35
|
+
- name: Create Release
|
|
36
|
+
run: gh release create ${{ steps.get-version.outputs.version }} --generate-notes
|
|
37
|
+
env:
|
|
38
|
+
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
name: Python Lint and Test
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
paths-ignore:
|
|
8
|
+
- "**.md"
|
|
9
|
+
push:
|
|
10
|
+
branches:
|
|
11
|
+
- main
|
|
12
|
+
paths-ignore:
|
|
13
|
+
- "**.md"
|
|
14
|
+
|
|
15
|
+
permissions:
|
|
16
|
+
contents: read
|
|
17
|
+
|
|
18
|
+
jobs:
|
|
19
|
+
Test:
|
|
20
|
+
runs-on: ubuntu-24.04
|
|
21
|
+
strategy:
|
|
22
|
+
matrix:
|
|
23
|
+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
|
|
24
|
+
fail-fast: false
|
|
25
|
+
|
|
26
|
+
steps:
|
|
27
|
+
- uses: actions/checkout@v6
|
|
28
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
29
|
+
uses: actions/setup-python@v6
|
|
30
|
+
with:
|
|
31
|
+
python-version: ${{ matrix.python-version }}
|
|
32
|
+
- name: Install dependencies
|
|
33
|
+
run: |
|
|
34
|
+
python -m pip install --upgrade pip
|
|
35
|
+
pip install ruff
|
|
36
|
+
pip install -e ".[dev]"
|
|
37
|
+
- name: Test with pytest
|
|
38
|
+
run: |
|
|
39
|
+
pytest --cov=keepassxc_browser_api --cov-report=term-missing
|
|
40
|
+
- name: Lint with ruff
|
|
41
|
+
env:
|
|
42
|
+
PY_VER: ${{ matrix.python-version }}
|
|
43
|
+
run: |
|
|
44
|
+
PY_VER=$(echo py${PY_VER} | tr -d '.')
|
|
45
|
+
ruff check --output-format=github --ignore=E501 --exclude=__init__.py --target-version=${PY_VER} ./keepassxc_browser_api
|
|
46
|
+
|
|
47
|
+
Check-Test:
|
|
48
|
+
if: ${{ always() }}
|
|
49
|
+
runs-on: ubuntu-24.04
|
|
50
|
+
needs:
|
|
51
|
+
- Test
|
|
52
|
+
steps:
|
|
53
|
+
- run: |
|
|
54
|
+
result="${{ needs.Test.result }}"
|
|
55
|
+
if [[ $result == "success" || $result == "skipped" ]]; then
|
|
56
|
+
exit 0
|
|
57
|
+
else
|
|
58
|
+
exit 1
|
|
59
|
+
fi
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
name: Build & Upload Python Package
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types:
|
|
6
|
+
- published
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
Setup:
|
|
13
|
+
runs-on: ubuntu-24.04
|
|
14
|
+
outputs:
|
|
15
|
+
version: ${{ steps.set-version.outputs.version }}
|
|
16
|
+
steps:
|
|
17
|
+
- name: Checkout
|
|
18
|
+
uses: actions/checkout@v6
|
|
19
|
+
with:
|
|
20
|
+
fetch-depth: 0
|
|
21
|
+
- name: Get Version
|
|
22
|
+
id: set-version
|
|
23
|
+
env:
|
|
24
|
+
VERSION: ${{ github.ref_name }}
|
|
25
|
+
run: |
|
|
26
|
+
if grep -c -E '^v[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}$' <<< ${VERSION}; then
|
|
27
|
+
VERSION=$(sed 's/^.\{1\}//g' <<< ${VERSION})
|
|
28
|
+
else
|
|
29
|
+
echo "This branch shouldn't be build: ${VERSION}"
|
|
30
|
+
exit 1
|
|
31
|
+
fi
|
|
32
|
+
echo "version=$(echo ${VERSION})" >> $GITHUB_OUTPUT
|
|
33
|
+
|
|
34
|
+
Deploy:
|
|
35
|
+
runs-on: ubuntu-24.04
|
|
36
|
+
needs: Setup
|
|
37
|
+
environment:
|
|
38
|
+
name: pypi
|
|
39
|
+
url: https://pypi.org/p/keepassxc-browser-api/
|
|
40
|
+
permissions:
|
|
41
|
+
id-token: write
|
|
42
|
+
contents: read
|
|
43
|
+
steps:
|
|
44
|
+
- uses: actions/checkout@v6
|
|
45
|
+
with:
|
|
46
|
+
fetch-depth: 0
|
|
47
|
+
- name: Set up Python
|
|
48
|
+
uses: actions/setup-python@v6
|
|
49
|
+
with:
|
|
50
|
+
python-version: '3.x'
|
|
51
|
+
- name: Install dependencies
|
|
52
|
+
run: |
|
|
53
|
+
python -m pip install --upgrade pip
|
|
54
|
+
pip install build
|
|
55
|
+
- name: Build package
|
|
56
|
+
env:
|
|
57
|
+
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ needs.Setup.outputs.version }}
|
|
58
|
+
run: python -m build
|
|
59
|
+
- name: Publish package
|
|
60
|
+
uses: pypa/gh-action-pypi-publish@v1.14.0
|
|
61
|
+
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
#uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
#poetry.lock
|
|
109
|
+
#poetry.toml
|
|
110
|
+
|
|
111
|
+
# pdm
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
113
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
114
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
115
|
+
#pdm.lock
|
|
116
|
+
#pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# pixi
|
|
121
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
122
|
+
#pixi.lock
|
|
123
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
124
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
125
|
+
.pixi
|
|
126
|
+
|
|
127
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
128
|
+
__pypackages__/
|
|
129
|
+
|
|
130
|
+
# Celery stuff
|
|
131
|
+
celerybeat-schedule
|
|
132
|
+
celerybeat.pid
|
|
133
|
+
|
|
134
|
+
# SageMath parsed files
|
|
135
|
+
*.sage.py
|
|
136
|
+
|
|
137
|
+
# Environments
|
|
138
|
+
.env
|
|
139
|
+
.envrc
|
|
140
|
+
.venv
|
|
141
|
+
env/
|
|
142
|
+
venv/
|
|
143
|
+
ENV/
|
|
144
|
+
env.bak/
|
|
145
|
+
venv.bak/
|
|
146
|
+
|
|
147
|
+
# Spyder project settings
|
|
148
|
+
.spyderproject
|
|
149
|
+
.spyproject
|
|
150
|
+
|
|
151
|
+
# Rope project settings
|
|
152
|
+
.ropeproject
|
|
153
|
+
|
|
154
|
+
# mkdocs documentation
|
|
155
|
+
/site
|
|
156
|
+
|
|
157
|
+
# mypy
|
|
158
|
+
.mypy_cache/
|
|
159
|
+
.dmypy.json
|
|
160
|
+
dmypy.json
|
|
161
|
+
|
|
162
|
+
# Pyre type checker
|
|
163
|
+
.pyre/
|
|
164
|
+
|
|
165
|
+
# pytype static type analyzer
|
|
166
|
+
.pytype/
|
|
167
|
+
|
|
168
|
+
# Cython debug symbols
|
|
169
|
+
cython_debug/
|
|
170
|
+
|
|
171
|
+
# PyCharm
|
|
172
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
173
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
174
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
175
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
176
|
+
#.idea/
|
|
177
|
+
|
|
178
|
+
# Abstra
|
|
179
|
+
# Abstra is an AI-powered process automation framework.
|
|
180
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
181
|
+
# Learn more at https://abstra.io/docs
|
|
182
|
+
.abstra/
|
|
183
|
+
|
|
184
|
+
# Visual Studio Code
|
|
185
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
186
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
187
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
188
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
189
|
+
# .vscode/
|
|
190
|
+
|
|
191
|
+
# Ruff stuff:
|
|
192
|
+
.ruff_cache/
|
|
193
|
+
|
|
194
|
+
# PyPI configuration file
|
|
195
|
+
.pypirc
|
|
196
|
+
|
|
197
|
+
# Cursor
|
|
198
|
+
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
|
|
199
|
+
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
|
|
200
|
+
# refer to https://docs.cursor.com/context/ignore-files
|
|
201
|
+
.cursorignore
|
|
202
|
+
.cursorindexingignore
|
|
203
|
+
|
|
204
|
+
# Marimo
|
|
205
|
+
marimo/_static/
|
|
206
|
+
marimo/_lsp/
|
|
207
|
+
__marimo__/
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# KeePassXC Browser API - Claude Code Instructions
|
|
2
|
+
|
|
3
|
+
## Project Overview
|
|
4
|
+
|
|
5
|
+
Python library implementing the KeePassXC browser extension protocol (NaCl-encrypted JSON over a Unix socket). Used by `keepassxc-cli` and `keepassxc-ssh-agent`.
|
|
6
|
+
|
|
7
|
+
## Architecture
|
|
8
|
+
|
|
9
|
+
- **`client.py`** — `BrowserClient`: handles connection, key exchange, association, and all API actions
|
|
10
|
+
- **`config.py`** — `BrowserConfig`: persistent config (keypair + associations) at `~/.keepassxc/browser-api.json`
|
|
11
|
+
- **`models.py`** — `Entry`, `Group` dataclasses for API responses
|
|
12
|
+
- **`exceptions.py`** — Custom exceptions hierarchy (`KeePassXCError` base)
|
|
13
|
+
|
|
14
|
+
### KeePassXC Browser Protocol Details
|
|
15
|
+
|
|
16
|
+
See **[PROTOCOL.md](PROTOCOL.md)** for the full protocol reference (wire format, encryption, all actions, error codes, source file links).
|
|
17
|
+
|
|
18
|
+
Quick summary:
|
|
19
|
+
- Socket: `$TMPDIR/org.keepassxc.KeePassXC.BrowserServer` (macOS), `$XDG_RUNTIME_DIR/.../org.keepassxc.KeePassXC.BrowserServer` (Linux)
|
|
20
|
+
- Every JSON message MUST include a `clientID` field; this library uses `"keepassxc-browser-api"`
|
|
21
|
+
- Key exchange via `change-public-keys` (unencrypted), all subsequent messages use NaCl `crypto_box`
|
|
22
|
+
- `get-databasehash` with `triggerUnlock=true` is NON-BLOCKING — returns immediately, must poll for unlock
|
|
23
|
+
- `test-associate` only works when DB is unlocked
|
|
24
|
+
- Relevant KeePassXC source: [`src/browser/BrowserAction.cpp`](https://github.com/keepassxreboot/keepassxc/blob/develop/src/browser/BrowserAction.cpp)
|
|
25
|
+
|
|
26
|
+
### Available API Actions
|
|
27
|
+
|
|
28
|
+
| Action | Method |
|
|
29
|
+
|---|---|
|
|
30
|
+
| `change-public-keys` | `change_public_keys()` |
|
|
31
|
+
| `associate` | `associate()` |
|
|
32
|
+
| `test-associate` | `test_associate(assoc)` |
|
|
33
|
+
| `get-databasehash` | `trigger_unlock()` / `ensure_unlocked()` |
|
|
34
|
+
| `get-logins` | `get_logins(url)` |
|
|
35
|
+
| `set-login` | `set_login(url, user, pw)` |
|
|
36
|
+
| `get-database-entries` | `get_database_entries()` |
|
|
37
|
+
| `get-database-groups` | `get_database_groups()` |
|
|
38
|
+
| `create-new-group` | `create_group(name)` |
|
|
39
|
+
| `get-totp` | `get_totp(uuid)` |
|
|
40
|
+
| `delete-entry` | `delete_entry(uuid)` |
|
|
41
|
+
| `lock-database` | `lock_database()` |
|
|
42
|
+
| `generate-password` | `generate_password()` |
|
|
43
|
+
|
|
44
|
+
## Commands
|
|
45
|
+
|
|
46
|
+
```shell
|
|
47
|
+
# Install
|
|
48
|
+
pip install -e ".[dev]"
|
|
49
|
+
|
|
50
|
+
# Run tests
|
|
51
|
+
pytest
|
|
52
|
+
|
|
53
|
+
# Run tests with coverage
|
|
54
|
+
pytest --cov=keepassxc_browser_api --cov-report=term-missing
|
|
55
|
+
|
|
56
|
+
# Lint
|
|
57
|
+
ruff check --ignore=E501 --exclude=__init__.py ./keepassxc_browser_api
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Conventions
|
|
61
|
+
|
|
62
|
+
- Python >= 3.10, no async (threading-based for simplicity)
|
|
63
|
+
- `from __future__ import annotations` in all source files
|
|
64
|
+
- PyNaCl for NaCl crypto (not raw libsodium)
|
|
65
|
+
- Config files use 0600 permissions (owner-only)
|
|
66
|
+
- Tests use `short_tmp` fixture for Unix socket paths (macOS `tmp_path` is too long for AF_UNIX)
|
|
67
|
+
- Shared config at `~/.keepassxc/browser-api.json` — consumed by both `keepassxc-cli` and `keepassxc-ssh-agent`
|
|
68
|
+
|
|
69
|
+
## CI
|
|
70
|
+
|
|
71
|
+
- `lint_and_test.yml` — Unit tests + ruff lint across Python 3.10–3.14
|
|
72
|
+
- `pypi.yml` — Build & publish on release, then dispatch to homebrew-tap to update the formula
|
|
73
|
+
- `auto-release.yml` — Auto-create patch release on dependabot merge
|
|
74
|
+
- `auto-merge-dependabot.yml` — Auto-merge dependabot PRs
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Nils
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: keepassxc-browser-api
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python library for the KeePassXC browser extension protocol
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Requires-Python: >=3.10
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Dist: PyNaCl==1.6.2
|
|
10
|
+
Provides-Extra: dev
|
|
11
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
12
|
+
Requires-Dist: pytest-cov>=4.0; extra == "dev"
|
|
13
|
+
Dynamic: license-file
|
|
14
|
+
|
|
15
|
+
# KeePassXC Browser API
|
|
16
|
+
|
|
17
|
+
Python library for communicating with [KeePassXC](https://keepassxc.org/) via the browser extension protocol (NaCl-encrypted JSON over a Unix socket).
|
|
18
|
+
|
|
19
|
+
## Features
|
|
20
|
+
|
|
21
|
+
- NaCl-encrypted communication with KeePassXC
|
|
22
|
+
- One-time association flow (user approves in KeePassXC window)
|
|
23
|
+
- Biometric unlock (TouchID / system unlock) via `triggerUnlock`
|
|
24
|
+
- Full browser API support: read entries, write entries, manage groups, TOTP, password generation, lock database
|
|
25
|
+
- Cross-platform: macOS and Linux
|
|
26
|
+
- Shared config (`~/.keepassxc/browser-api.json`) — associate once, use with all tools
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
```shell
|
|
31
|
+
pip install keepassxc-browser-api
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Quick start
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
from keepassxc_browser_api import BrowserClient, BrowserConfig
|
|
38
|
+
|
|
39
|
+
config = BrowserConfig.load()
|
|
40
|
+
client = BrowserClient(config)
|
|
41
|
+
|
|
42
|
+
# First time: associate with KeePassXC (requires user approval)
|
|
43
|
+
if not config.associations:
|
|
44
|
+
client.setup()
|
|
45
|
+
config.save()
|
|
46
|
+
|
|
47
|
+
# Ensure DB is unlocked (triggers TouchID/biometrics if locked)
|
|
48
|
+
client.ensure_unlocked()
|
|
49
|
+
|
|
50
|
+
# API methods auto-connect when needed
|
|
51
|
+
entries = client.get_logins("https://example.com")
|
|
52
|
+
for e in entries:
|
|
53
|
+
print(e.name, e.login)
|
|
54
|
+
|
|
55
|
+
# Clean up when done
|
|
56
|
+
client.disconnect()
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Or use the context manager for automatic cleanup:
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
with BrowserClient(config) as client:
|
|
63
|
+
entries = client.get_logins("https://example.com")
|
|
64
|
+
totp = client.get_totp(entries[0].uuid)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## API
|
|
68
|
+
|
|
69
|
+
### `BrowserClient`
|
|
70
|
+
|
|
71
|
+
| Method | Description |
|
|
72
|
+
|---|---|
|
|
73
|
+
| `setup()` | First-time association (user approves in KeePassXC) |
|
|
74
|
+
| `ensure_unlocked()` | Connect and unlock (triggers TouchID if locked) |
|
|
75
|
+
| `get_logins(url, ...)` | Find entries matching a URL |
|
|
76
|
+
| `set_login(url, username, password, ...)` | Create or update an entry |
|
|
77
|
+
| `get_database_entries()` | Return all entries |
|
|
78
|
+
| `get_database_groups()` | Return all groups (tree) |
|
|
79
|
+
| `create_group(name, parent_uuid)` | Create a new group |
|
|
80
|
+
| `get_totp(uuid)` | Get TOTP code for an entry |
|
|
81
|
+
| `delete_entry(uuid)` | Delete an entry |
|
|
82
|
+
| `lock_database()` | Lock the database |
|
|
83
|
+
| `generate_password()` | Generate a password (uses KeePassXC settings) |
|
|
84
|
+
| `request_autotype(search)` | Trigger KeePassXC global auto-type |
|
|
85
|
+
|
|
86
|
+
> **Note**: `passkeys-get` and `passkeys-register` are not implemented. They require complex WebAuthn/CBOR data structures and are only available in KeePassXC builds compiled with `WITH_XC_BROWSER_PASSKEYS`.
|
|
87
|
+
|
|
88
|
+
### `BrowserConfig`
|
|
89
|
+
|
|
90
|
+
Configuration stored at `~/.keepassxc/browser-api.json` (mode 0600).
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
config = BrowserConfig.load() # Load from default path
|
|
94
|
+
config = BrowserConfig.load(path) # Load from custom path
|
|
95
|
+
config.save() # Save to default path
|
|
96
|
+
config.save(path) # Save to custom path
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Protocol documentation
|
|
100
|
+
|
|
101
|
+
For a detailed description of the KeePassXC browser extension protocol (wire format, encryption, all actions, error codes), see **[PROTOCOL.md](PROTOCOL.md)**.
|
|
102
|
+
|
|
103
|
+
## Development
|
|
104
|
+
|
|
105
|
+
```shell
|
|
106
|
+
# Install in editable mode with dev dependencies
|
|
107
|
+
pip install -e ".[dev]"
|
|
108
|
+
|
|
109
|
+
# Run tests
|
|
110
|
+
pytest
|
|
111
|
+
|
|
112
|
+
# Run tests with coverage
|
|
113
|
+
pytest --cov=keepassxc_browser_api
|
|
114
|
+
|
|
115
|
+
# Lint
|
|
116
|
+
ruff check --ignore=E501 --exclude=__init__.py ./keepassxc_browser_api
|
|
117
|
+
```
|