agent-core-credentials 0.8.2__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.
- agent_core_credentials-0.8.2/.gitignore +245 -0
- agent_core_credentials-0.8.2/CHANGELOG.md +32 -0
- agent_core_credentials-0.8.2/PKG-INFO +11 -0
- agent_core_credentials-0.8.2/VERSION +1 -0
- agent_core_credentials-0.8.2/pyproject.toml +32 -0
- agent_core_credentials-0.8.2/src/agent_core_credentials/__init__.py +67 -0
- agent_core_credentials-0.8.2/src/agent_core_credentials/cli.py +156 -0
- agent_core_credentials-0.8.2/src/agent_core_credentials/master_password.py +217 -0
- agent_core_credentials-0.8.2/src/agent_core_credentials/models.py +27 -0
- agent_core_credentials-0.8.2/src/agent_core_credentials/py.typed +0 -0
- agent_core_credentials-0.8.2/src/agent_core_credentials/secrets.py +66 -0
- agent_core_credentials-0.8.2/src/agent_core_credentials/store.py +134 -0
- agent_core_credentials-0.8.2/tests/conftest.py +64 -0
- agent_core_credentials-0.8.2/tests/test_cli.py +262 -0
- agent_core_credentials-0.8.2/tests/test_master_password.py +228 -0
- agent_core_credentials-0.8.2/tests/test_models.py +36 -0
- agent_core_credentials-0.8.2/tests/test_secrets.py +68 -0
- agent_core_credentials-0.8.2/tests/test_store.py +125 -0
- agent_core_credentials-0.8.2/towncrier.toml +38 -0
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
# Memory compiler runtime state
|
|
2
|
+
memory-compiler/daily/
|
|
3
|
+
memory-compiler/reports/
|
|
4
|
+
memory-compiler/scripts/state.json
|
|
5
|
+
memory-compiler/scripts/last-flush.json
|
|
6
|
+
memory-compiler/scripts/flush.log
|
|
7
|
+
memory-compiler/scripts/compile.log
|
|
8
|
+
memory-compiler/scripts/session-flush-*.md
|
|
9
|
+
memory-compiler/scripts/flush-context-*.md
|
|
10
|
+
|
|
11
|
+
# Handoff writer state (placed alongside handoff files)
|
|
12
|
+
**/handoff-state.json
|
|
13
|
+
|
|
14
|
+
# Git worktrees (superpowers / parallel feature work)
|
|
15
|
+
.worktrees/
|
|
16
|
+
# Native (harness) worktrees
|
|
17
|
+
.claude/worktrees/
|
|
18
|
+
|
|
19
|
+
# Superpowers brainstorm mockups / scratch
|
|
20
|
+
.superpowers/
|
|
21
|
+
|
|
22
|
+
# Agent-core runtime state (handoffs, bus.sqlite, transcripts, etc.)
|
|
23
|
+
.agent-core/
|
|
24
|
+
|
|
25
|
+
# Local scratch / smoke-test artifacts
|
|
26
|
+
.tmp/
|
|
27
|
+
|
|
28
|
+
# Claude Code per-machine local overrides
|
|
29
|
+
.claude/settings.local.json
|
|
30
|
+
.claude/*.lock
|
|
31
|
+
|
|
32
|
+
# Byte-compiled / optimized / DLL files
|
|
33
|
+
__pycache__/
|
|
34
|
+
*.py[codz]
|
|
35
|
+
*$py.class
|
|
36
|
+
|
|
37
|
+
# C extensions
|
|
38
|
+
*.so
|
|
39
|
+
|
|
40
|
+
# Distribution / packaging
|
|
41
|
+
.Python
|
|
42
|
+
build/
|
|
43
|
+
develop-eggs/
|
|
44
|
+
dist/
|
|
45
|
+
downloads/
|
|
46
|
+
eggs/
|
|
47
|
+
.eggs/
|
|
48
|
+
lib/
|
|
49
|
+
lib64/
|
|
50
|
+
parts/
|
|
51
|
+
sdist/
|
|
52
|
+
var/
|
|
53
|
+
wheels/
|
|
54
|
+
share/python-wheels/
|
|
55
|
+
*.egg-info/
|
|
56
|
+
.installed.cfg
|
|
57
|
+
*.egg
|
|
58
|
+
MANIFEST
|
|
59
|
+
|
|
60
|
+
# PyInstaller
|
|
61
|
+
# Usually these files are written by a python script from a template
|
|
62
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
63
|
+
*.manifest
|
|
64
|
+
*.spec
|
|
65
|
+
|
|
66
|
+
# Installer logs
|
|
67
|
+
pip-log.txt
|
|
68
|
+
pip-delete-this-directory.txt
|
|
69
|
+
|
|
70
|
+
# Unit test / coverage reports
|
|
71
|
+
htmlcov/
|
|
72
|
+
.tox/
|
|
73
|
+
.nox/
|
|
74
|
+
.coverage
|
|
75
|
+
.coverage.*
|
|
76
|
+
.cache
|
|
77
|
+
nosetests.xml
|
|
78
|
+
coverage.xml
|
|
79
|
+
*.cover
|
|
80
|
+
*.py.cover
|
|
81
|
+
.hypothesis/
|
|
82
|
+
.pytest_cache/
|
|
83
|
+
cover/
|
|
84
|
+
|
|
85
|
+
# Translations
|
|
86
|
+
*.mo
|
|
87
|
+
*.pot
|
|
88
|
+
|
|
89
|
+
# Django stuff:
|
|
90
|
+
*.log
|
|
91
|
+
local_settings.py
|
|
92
|
+
db.sqlite3
|
|
93
|
+
db.sqlite3-journal
|
|
94
|
+
|
|
95
|
+
# Flask stuff:
|
|
96
|
+
instance/
|
|
97
|
+
.webassets-cache
|
|
98
|
+
|
|
99
|
+
# Scrapy stuff:
|
|
100
|
+
.scrapy
|
|
101
|
+
|
|
102
|
+
# Sphinx documentation
|
|
103
|
+
docs/_build/
|
|
104
|
+
|
|
105
|
+
# PyBuilder
|
|
106
|
+
.pybuilder/
|
|
107
|
+
target/
|
|
108
|
+
|
|
109
|
+
# Jupyter Notebook
|
|
110
|
+
.ipynb_checkpoints
|
|
111
|
+
|
|
112
|
+
# IPython
|
|
113
|
+
profile_default/
|
|
114
|
+
ipython_config.py
|
|
115
|
+
|
|
116
|
+
# pyenv
|
|
117
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
118
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
119
|
+
# .python-version
|
|
120
|
+
|
|
121
|
+
# pipenv
|
|
122
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
123
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
124
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
125
|
+
# install all needed dependencies.
|
|
126
|
+
#Pipfile.lock
|
|
127
|
+
|
|
128
|
+
# UV
|
|
129
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
130
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
131
|
+
# commonly ignored for libraries.
|
|
132
|
+
#uv.lock
|
|
133
|
+
|
|
134
|
+
# poetry
|
|
135
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
136
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
137
|
+
# commonly ignored for libraries.
|
|
138
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
139
|
+
#poetry.lock
|
|
140
|
+
#poetry.toml
|
|
141
|
+
|
|
142
|
+
# pdm
|
|
143
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
144
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
145
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
146
|
+
#pdm.lock
|
|
147
|
+
#pdm.toml
|
|
148
|
+
.pdm-python
|
|
149
|
+
.pdm-build/
|
|
150
|
+
|
|
151
|
+
# pixi
|
|
152
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
153
|
+
#pixi.lock
|
|
154
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
155
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
156
|
+
.pixi
|
|
157
|
+
|
|
158
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
159
|
+
__pypackages__/
|
|
160
|
+
|
|
161
|
+
# Celery stuff
|
|
162
|
+
celerybeat-schedule
|
|
163
|
+
celerybeat.pid
|
|
164
|
+
|
|
165
|
+
# SageMath parsed files
|
|
166
|
+
*.sage.py
|
|
167
|
+
|
|
168
|
+
# Environments
|
|
169
|
+
.env
|
|
170
|
+
.envrc
|
|
171
|
+
.venv
|
|
172
|
+
env/
|
|
173
|
+
venv/
|
|
174
|
+
ENV/
|
|
175
|
+
env.bak/
|
|
176
|
+
venv.bak/
|
|
177
|
+
|
|
178
|
+
# Spyder project settings
|
|
179
|
+
.spyderproject
|
|
180
|
+
.spyproject
|
|
181
|
+
|
|
182
|
+
# Rope project settings
|
|
183
|
+
.ropeproject
|
|
184
|
+
|
|
185
|
+
# mkdocs documentation
|
|
186
|
+
/site
|
|
187
|
+
|
|
188
|
+
# mypy
|
|
189
|
+
.mypy_cache/
|
|
190
|
+
.dmypy.json
|
|
191
|
+
dmypy.json
|
|
192
|
+
|
|
193
|
+
# Pyre type checker
|
|
194
|
+
.pyre/
|
|
195
|
+
|
|
196
|
+
# pytype static type analyzer
|
|
197
|
+
.pytype/
|
|
198
|
+
|
|
199
|
+
# Cython debug symbols
|
|
200
|
+
cython_debug/
|
|
201
|
+
|
|
202
|
+
# PyCharm
|
|
203
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
204
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
205
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
206
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
207
|
+
#.idea/
|
|
208
|
+
|
|
209
|
+
# Abstra
|
|
210
|
+
# Abstra is an AI-powered process automation framework.
|
|
211
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
212
|
+
# Learn more at https://abstra.io/docs
|
|
213
|
+
.abstra/
|
|
214
|
+
|
|
215
|
+
# Visual Studio Code
|
|
216
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
217
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
218
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
219
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
220
|
+
# .vscode/
|
|
221
|
+
|
|
222
|
+
# Ruff stuff:
|
|
223
|
+
.ruff_cache/
|
|
224
|
+
|
|
225
|
+
# PyPI configuration file
|
|
226
|
+
.pypirc
|
|
227
|
+
|
|
228
|
+
# Cursor
|
|
229
|
+
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
|
|
230
|
+
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
|
|
231
|
+
# refer to https://docs.cursor.com/context/ignore-files
|
|
232
|
+
.cursorignore
|
|
233
|
+
.cursorindexingignore
|
|
234
|
+
|
|
235
|
+
# Marimo
|
|
236
|
+
marimo/_static/
|
|
237
|
+
marimo/_lsp/
|
|
238
|
+
__marimo__/
|
|
239
|
+
.gstack/
|
|
240
|
+
|
|
241
|
+
# macOS Finder metadata (occasionally sneaks in via vendored sources)
|
|
242
|
+
.DS_Store
|
|
243
|
+
|
|
244
|
+
# Operational docs that must not live in source control
|
|
245
|
+
pepper-vault-plan.txt
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.8.1](https://github.com/jeffrichley/agent_core/compare/v0.8.0...agent-core-credentials-v0.8.1) (2026-07-22)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* republish package family to complete rate-limited first publish ([#477](https://github.com/jeffrichley/agent_core/issues/477)) ([32977ac](https://github.com/jeffrichley/agent_core/commit/32977ac78da4a15553329bb4e1fdaa9e894834ad))
|
|
9
|
+
|
|
10
|
+
## [0.8.0](https://github.com/jeffrichley/agent_core/compare/v0.7.0...agent-core-credentials-v0.8.0) (2026-07-21)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* **credentials:** add keyring master-password store with encrypted-file fallback ([#413](https://github.com/jeffrichley/agent_core/issues/413)) ([b5b8dd6](https://github.com/jeffrichley/agent_core/commit/b5b8dd6c671b9015ba5935540a6ded33dba13f91))
|
|
16
|
+
* **credentials:** make creds get metadata-only, remove stdout secret emission ([#411](https://github.com/jeffrichley/agent_core/issues/411)) ([8aae1e5](https://github.com/jeffrichley/agent_core/commit/8aae1e575f3791998b95a7dbe1e787353d7c0788))
|
|
17
|
+
* **hatchery:** ungendered templates + .mcp.json generation ([#81](https://github.com/jeffrichley/agent_core/issues/81)/[#82](https://github.com/jeffrichley/agent_core/issues/82)) ([#357](https://github.com/jeffrichley/agent_core/issues/357)) ([f48762d](https://github.com/jeffrichley/agent_core/commit/f48762df78eb12cfa9524e9b5a277741534ea8a7)), closes [#311](https://github.com/jeffrichley/agent_core/issues/311)
|
|
18
|
+
* **release:** configure release-please for 12-package synchronized version train ([#428](https://github.com/jeffrichley/agent_core/issues/428)) ([c1b4097](https://github.com/jeffrichley/agent_core/commit/c1b409765c61d09a6657b0e8b5e43a27cb235b3e))
|
|
19
|
+
* **secrets:** add vault-API accessor and scrub subprocess env ([#399](https://github.com/jeffrichley/agent_core/issues/399)) ([adb404b](https://github.com/jeffrichley/agent_core/commit/adb404b046bd224b56d64188b2cb56eb134d99b7))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Bug Fixes
|
|
23
|
+
|
|
24
|
+
* 6 HIGH findings from the adversarial review (leaks, fragility, footguns) ([#469](https://github.com/jeffrichley/agent_core/issues/469)) ([f546c54](https://github.com/jeffrichley/agent_core/commit/f546c548d2da6455e611c5b5820a21fa8c86211e))
|
|
25
|
+
|
|
26
|
+
## Changelog
|
|
27
|
+
|
|
28
|
+
All notable changes to `agent-core-credentials` are documented in this
|
|
29
|
+
file. The format is generated by towncrier from fragments in
|
|
30
|
+
`changelog.d/` at release time.
|
|
31
|
+
|
|
32
|
+
<!-- towncrier release notes start -->
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: agent-core-credentials
|
|
3
|
+
Version: 0.8.2
|
|
4
|
+
Summary: KeePass-backed credential vault for agent-core agents
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Requires-Python: >=3.12
|
|
7
|
+
Requires-Dist: cryptography>=41.0
|
|
8
|
+
Requires-Dist: keyring>=24.0
|
|
9
|
+
Requires-Dist: pykeepass>=4.1.1.post1
|
|
10
|
+
Requires-Dist: rich>=13.0
|
|
11
|
+
Requires-Dist: typer>=0.12
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.8.1
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "agent-core-credentials"
|
|
3
|
+
dynamic = ["version"]
|
|
4
|
+
description = "KeePass-backed credential vault for agent-core agents"
|
|
5
|
+
license = "MIT"
|
|
6
|
+
requires-python = ">=3.12"
|
|
7
|
+
dependencies = [
|
|
8
|
+
"pykeepass>=4.1.1.post1",
|
|
9
|
+
"typer>=0.12",
|
|
10
|
+
"rich>=13.0",
|
|
11
|
+
"keyring>=24.0",
|
|
12
|
+
"cryptography>=41.0",
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
[project.scripts]
|
|
16
|
+
agent-core-creds = "agent_core_credentials.cli:creds_app"
|
|
17
|
+
|
|
18
|
+
[build-system]
|
|
19
|
+
requires = ["hatchling", "uv-dynamic-versioning"]
|
|
20
|
+
build-backend = "hatchling.build"
|
|
21
|
+
|
|
22
|
+
[tool.hatch.build.targets.wheel]
|
|
23
|
+
packages = ["src/agent_core_credentials"]
|
|
24
|
+
|
|
25
|
+
[tool.hatch.version]
|
|
26
|
+
source = "uv-dynamic-versioning"
|
|
27
|
+
|
|
28
|
+
[tool.uv-dynamic-versioning]
|
|
29
|
+
fallback-version = "0.0.0"
|
|
30
|
+
|
|
31
|
+
[tool.uv]
|
|
32
|
+
cache-keys = [{ file = "pyproject.toml" }, { git = { commit = true, tags = true } }]
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"""agent_core_credentials — KeePass-backed credential vault.
|
|
2
|
+
|
|
3
|
+
Public API for credential operations. Used by the CLI and available
|
|
4
|
+
for direct import elsewhere.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import os
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
|
|
12
|
+
from agent_core_credentials.master_password import get_master_password, set_master_password
|
|
13
|
+
from agent_core_credentials.models import Credential, CredentialSummary
|
|
14
|
+
from agent_core_credentials.secrets import SecretNotFoundError, get
|
|
15
|
+
from agent_core_credentials.store import CredentialStore
|
|
16
|
+
|
|
17
|
+
__all__ = [
|
|
18
|
+
"Credential",
|
|
19
|
+
"CredentialSummary",
|
|
20
|
+
"SecretNotFoundError",
|
|
21
|
+
"default_vault_path",
|
|
22
|
+
"delete_credential",
|
|
23
|
+
"get",
|
|
24
|
+
"get_credential",
|
|
25
|
+
"get_master_password",
|
|
26
|
+
"list_credentials",
|
|
27
|
+
"set_credential",
|
|
28
|
+
"set_master_password",
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def default_vault_path() -> Path:
|
|
33
|
+
"""Resolve the default vault path.
|
|
34
|
+
|
|
35
|
+
Honours the AGENT_CORE_VAULT_PATH env var if set; otherwise falls
|
|
36
|
+
back to ~/.agent-core/credentials.kdbx.
|
|
37
|
+
"""
|
|
38
|
+
override = os.environ.get("AGENT_CORE_VAULT_PATH")
|
|
39
|
+
if override:
|
|
40
|
+
return Path(override)
|
|
41
|
+
return Path.home() / ".agent-core" / "credentials.kdbx"
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def get_credential(service: str) -> Credential | None:
|
|
45
|
+
"""Retrieve a credential by service name."""
|
|
46
|
+
return CredentialStore(default_vault_path()).get(service)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def set_credential(
|
|
50
|
+
service: str,
|
|
51
|
+
username: str,
|
|
52
|
+
password: str,
|
|
53
|
+
url: str = "",
|
|
54
|
+
notes: str = "",
|
|
55
|
+
) -> None:
|
|
56
|
+
"""Store or overwrite a credential."""
|
|
57
|
+
CredentialStore(default_vault_path()).set(service, username, password, url, notes)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def list_credentials() -> list[CredentialSummary]:
|
|
61
|
+
"""List all stored credentials without passwords."""
|
|
62
|
+
return CredentialStore(default_vault_path()).list()
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def delete_credential(service: str) -> bool:
|
|
66
|
+
"""Delete a credential. Returns True if found and deleted."""
|
|
67
|
+
return CredentialStore(default_vault_path()).delete(service)
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"""agent-core creds CLI — manage stored credentials."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
import os
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
import typer
|
|
10
|
+
from pykeepass import create_database # type: ignore[import-untyped]
|
|
11
|
+
from rich import print as rprint
|
|
12
|
+
|
|
13
|
+
from agent_core_credentials import default_vault_path
|
|
14
|
+
from agent_core_credentials.master_password import set_master_password
|
|
15
|
+
from agent_core_credentials.store import CredentialStore
|
|
16
|
+
|
|
17
|
+
creds_app = typer.Typer(
|
|
18
|
+
name="creds",
|
|
19
|
+
help="Manage stored credentials.",
|
|
20
|
+
no_args_is_help=True,
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
# Default paths — overridden in tests via monkeypatch
|
|
24
|
+
_vault_path = default_vault_path()
|
|
25
|
+
_env_path = Path.home() / ".agent-core" / ".env"
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def _load_env() -> None:
|
|
29
|
+
"""Load .env into the process environment if not already set."""
|
|
30
|
+
if os.environ.get("AGENT_CORE_VAULT_PASSWORD"):
|
|
31
|
+
return
|
|
32
|
+
if _env_path.exists():
|
|
33
|
+
for line in _env_path.read_text().splitlines():
|
|
34
|
+
if "=" in line and not line.startswith("#"):
|
|
35
|
+
key, _, value = line.partition("=")
|
|
36
|
+
os.environ.setdefault(key.strip(), value.strip())
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def _store() -> CredentialStore:
|
|
40
|
+
"""Create a CredentialStore for the current vault path."""
|
|
41
|
+
_load_env()
|
|
42
|
+
return CredentialStore(_vault_path)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
@creds_app.command("init")
|
|
46
|
+
def init_vault() -> None:
|
|
47
|
+
"""Initialize the credential vault with a master password."""
|
|
48
|
+
if _vault_path.exists():
|
|
49
|
+
rprint(f"[red]Credential vault already exists at {_vault_path}[/red]")
|
|
50
|
+
raise typer.Exit(1)
|
|
51
|
+
|
|
52
|
+
password = typer.prompt("Master password", hide_input=True)
|
|
53
|
+
confirm = typer.prompt("Confirm password", hide_input=True)
|
|
54
|
+
|
|
55
|
+
if password != confirm:
|
|
56
|
+
rprint("[red]Passwords do not match.[/red]")
|
|
57
|
+
raise typer.Exit(1)
|
|
58
|
+
|
|
59
|
+
_vault_path.parent.mkdir(parents=True, exist_ok=True)
|
|
60
|
+
create_database(str(_vault_path), password=password)
|
|
61
|
+
|
|
62
|
+
set_master_password(_vault_path, password)
|
|
63
|
+
|
|
64
|
+
rprint(f"[green]Created credential vault at {_vault_path}[/green]")
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
@creds_app.command("set")
|
|
68
|
+
def set_credential(
|
|
69
|
+
service: str = typer.Argument(help="Service name (e.g. apex, etsy)"),
|
|
70
|
+
) -> None:
|
|
71
|
+
"""Store a credential with secure password input."""
|
|
72
|
+
username = typer.prompt("Username")
|
|
73
|
+
password = typer.prompt("Password", hide_input=True)
|
|
74
|
+
url = typer.prompt("URL (optional)", default="")
|
|
75
|
+
notes = typer.prompt("Notes (optional)", default="")
|
|
76
|
+
|
|
77
|
+
try:
|
|
78
|
+
_store().set(service, username, password, url, notes)
|
|
79
|
+
except ValueError as e:
|
|
80
|
+
rprint(f"[red]{e}[/red]")
|
|
81
|
+
raise typer.Exit(1) from None
|
|
82
|
+
|
|
83
|
+
rprint(f"[green]Saved {service}[/green]")
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
@creds_app.command("get")
|
|
87
|
+
def get_credential(
|
|
88
|
+
service: str = typer.Argument(help="Service name to retrieve"),
|
|
89
|
+
as_json: bool = typer.Option(False, "--json", help="Output as JSON (metadata only, no secret)"),
|
|
90
|
+
) -> None:
|
|
91
|
+
"""Retrieve a stored credential."""
|
|
92
|
+
try:
|
|
93
|
+
cred = _store().get(service)
|
|
94
|
+
except ValueError as e:
|
|
95
|
+
rprint(f"[red]{e}[/red]")
|
|
96
|
+
raise typer.Exit(1) from None
|
|
97
|
+
|
|
98
|
+
if cred is None:
|
|
99
|
+
rprint(f"[red]No credential found for {service}[/red]")
|
|
100
|
+
raise typer.Exit(1)
|
|
101
|
+
|
|
102
|
+
if as_json:
|
|
103
|
+
print(json.dumps({"name": cred.service, "exists": True, "length": len(cred.password)}))
|
|
104
|
+
else:
|
|
105
|
+
rprint(f"[bold]Service:[/bold] {cred.service}")
|
|
106
|
+
rprint(f"[bold]Length:[/bold] {len(cred.password)} chars")
|
|
107
|
+
if cred.mtime is not None:
|
|
108
|
+
rprint(f"[bold]Modified:[/bold] {cred.mtime.strftime('%Y-%m-%d %H:%M UTC')}")
|
|
109
|
+
else:
|
|
110
|
+
rprint("[bold]Modified:[/bold] (unknown)")
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
@creds_app.command("list")
|
|
114
|
+
def list_credentials(
|
|
115
|
+
as_json: bool = typer.Option(False, "--json", help="Output as JSON"),
|
|
116
|
+
) -> None:
|
|
117
|
+
"""List all stored credentials."""
|
|
118
|
+
try:
|
|
119
|
+
summaries = _store().list()
|
|
120
|
+
except ValueError as e:
|
|
121
|
+
rprint(f"[red]{e}[/red]")
|
|
122
|
+
raise typer.Exit(1) from None
|
|
123
|
+
|
|
124
|
+
if as_json:
|
|
125
|
+
print(
|
|
126
|
+
json.dumps(
|
|
127
|
+
[
|
|
128
|
+
{"service": s.service, "username": s.username, "url": s.url}
|
|
129
|
+
for s in summaries
|
|
130
|
+
]
|
|
131
|
+
)
|
|
132
|
+
)
|
|
133
|
+
else:
|
|
134
|
+
if not summaries:
|
|
135
|
+
rprint("[yellow]No credentials stored.[/yellow]")
|
|
136
|
+
return
|
|
137
|
+
for s in summaries:
|
|
138
|
+
rprint(s.service)
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
@creds_app.command("delete")
|
|
142
|
+
def delete_credential(
|
|
143
|
+
service: str = typer.Argument(help="Service name to delete"),
|
|
144
|
+
) -> None:
|
|
145
|
+
"""Delete a stored credential."""
|
|
146
|
+
try:
|
|
147
|
+
deleted = _store().delete(service)
|
|
148
|
+
except ValueError as e:
|
|
149
|
+
rprint(f"[red]{e}[/red]")
|
|
150
|
+
raise typer.Exit(1) from None
|
|
151
|
+
|
|
152
|
+
if not deleted:
|
|
153
|
+
rprint(f"[red]No credential found for {service}[/red]")
|
|
154
|
+
raise typer.Exit(1)
|
|
155
|
+
|
|
156
|
+
rprint(f"[green]Deleted {service}[/green]")
|