openentity 0.5.2__tar.gz → 0.5.3__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 (24) hide show
  1. {openentity-0.5.2 → openentity-0.5.3}/PKG-INFO +1 -1
  2. {openentity-0.5.2 → openentity-0.5.3}/openentity/__init__.py +1 -1
  3. {openentity-0.5.2 → openentity-0.5.3}/openentity/identity.py +14 -2
  4. {openentity-0.5.2 → openentity-0.5.3}/pyproject.toml +1 -1
  5. {openentity-0.5.2 → openentity-0.5.3}/tests/test_core.py +2 -2
  6. {openentity-0.5.2 → openentity-0.5.3}/tests/test_identity.py +12 -0
  7. {openentity-0.5.2 → openentity-0.5.3}/uv.lock +1 -1
  8. {openentity-0.5.2 → openentity-0.5.3}/.gitignore +0 -0
  9. {openentity-0.5.2 → openentity-0.5.3}/README.md +0 -0
  10. {openentity-0.5.2 → openentity-0.5.3}/openentity/cli.py +0 -0
  11. {openentity-0.5.2 → openentity-0.5.3}/openentity/client.py +0 -0
  12. {openentity-0.5.2 → openentity-0.5.3}/openentity/core.py +0 -0
  13. {openentity-0.5.2 → openentity-0.5.3}/openentity/httpsig.py +0 -0
  14. {openentity-0.5.2 → openentity-0.5.3}/openentity/issuer.py +0 -0
  15. {openentity-0.5.2 → openentity-0.5.3}/openentity/report.py +0 -0
  16. {openentity-0.5.2 → openentity-0.5.3}/openentity/schema.py +0 -0
  17. {openentity-0.5.2 → openentity-0.5.3}/openentity/schemas/openentity-1.0.json +0 -0
  18. {openentity-0.5.2 → openentity-0.5.3}/tests/test_cli.py +0 -0
  19. {openentity-0.5.2 → openentity-0.5.3}/tests/test_client.py +0 -0
  20. {openentity-0.5.2 → openentity-0.5.3}/tests/test_httpsig.py +0 -0
  21. {openentity-0.5.2 → openentity-0.5.3}/tests/test_issuer.py +0 -0
  22. {openentity-0.5.2 → openentity-0.5.3}/tests/test_parity.py +0 -0
  23. {openentity-0.5.2 → openentity-0.5.3}/tests/test_trust.py +0 -0
  24. {openentity-0.5.2 → openentity-0.5.3}/tests/test_verifier.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: openentity
3
- Version: 0.5.2
3
+ Version: 0.5.3
4
4
  Summary: Open Entity (OEIS-1) client: JCS, did:key, eddsa-jcs-2022, Merkle proofs, adopt().
5
5
  Project-URL: Homepage, https://openentity.org
6
6
  Project-URL: Documentation, https://oeis.dev
@@ -5,4 +5,4 @@ from .httpsig import HttpSigError, sign_request, verify_request # noqa: F401
5
5
  from .identity import Identity # noqa: F401
6
6
  from .report import TrustReport, trust # noqa: F401
7
7
 
8
- __version__ = "0.5.2"
8
+ __version__ = "0.5.3"
@@ -37,8 +37,13 @@ def _keychain_set(seed_hex: str) -> bool:
37
37
  return False
38
38
 
39
39
 
40
+ def home() -> pathlib.Path:
41
+ """OPENENTITY_HOME, else ~/.openentity: where the key file and integrations' state live."""
42
+ return pathlib.Path(os.environ.get("OPENENTITY_HOME", "~/.openentity")).expanduser()
43
+
44
+
40
45
  def _file() -> pathlib.Path:
41
- return pathlib.Path(os.environ.get("OPENENTITY_HOME", "~/.openentity")).expanduser() / "identity.key"
46
+ return home() / "identity.key"
42
47
 
43
48
 
44
49
  class Identity:
@@ -54,10 +59,17 @@ class Identity:
54
59
  return self.kp.seed
55
60
 
56
61
  @classmethod
57
- def load_or_create(cls) -> "Identity":
62
+ def load(cls) -> "Identity | None":
63
+ """The existing identity, or None. Never creates one."""
58
64
  for source, read in (("keychain", _keychain_get), ("file", lambda: _file().read_text().strip() if _file().exists() else None)):
59
65
  if h := read():
60
66
  return cls(bytes.fromhex(h), source)
67
+ return None
68
+
69
+ @classmethod
70
+ def load_or_create(cls) -> "Identity":
71
+ if found := cls.load():
72
+ return found
61
73
  seed = os.urandom(32)
62
74
  if _keychain_set(seed.hex()):
63
75
  return cls(seed, "keychain")
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "openentity"
7
- version = "0.5.2"
7
+ version = "0.5.3"
8
8
  description = "Open Entity (OEIS-1) client: JCS, did:key, eddsa-jcs-2022, Merkle proofs, adopt()."
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -7,7 +7,7 @@ from pathlib import Path
7
7
 
8
8
  import pytest
9
9
 
10
- from openentity import cli, core
10
+ from openentity import __version__, cli, core
11
11
 
12
12
  ROOT = Path(__file__).resolve().parents[3]
13
13
  VECTORS = ROOT / "test-vectors"
@@ -198,7 +198,7 @@ def test_adopt_and_cli(tmp_path, monkeypatch, capsys):
198
198
  def test_cli_version(capsys):
199
199
  with pytest.raises(SystemExit) as e:
200
200
  cli.main(["--version"])
201
- assert e.value.code == 0 and "0.5.2" in capsys.readouterr().out
201
+ assert e.value.code == 0 and __version__ in capsys.readouterr().out
202
202
 
203
203
 
204
204
  # ---- shared vectors, checked with the independent verifier's own logic ----
@@ -45,3 +45,15 @@ def test_keychain_failure_falls_back_to_file(monkeypatch):
45
45
  monkeypatch.delenv("OPENENTITY_KEYCHAIN")
46
46
  monkeypatch.setattr(identity, "_run", lambda argv, stdin=None: None) # no `security`, no `secret-tool`
47
47
  assert Identity.load_or_create().source == "file"
48
+
49
+
50
+ def test_load_never_creates_a_key(home):
51
+ """Read-only callers (a trust gate) must not mint an identity as a side effect."""
52
+ assert Identity.load() is None
53
+ assert not (home / "identity.key").exists()
54
+ a = Identity.load_or_create()
55
+ assert Identity.load().did == a.did
56
+
57
+
58
+ def test_home_follows_openentity_home(home):
59
+ assert identity.home() == home
@@ -699,7 +699,7 @@ wheels = [
699
699
 
700
700
  [[package]]
701
701
  name = "openentity"
702
- version = "0.5.2"
702
+ version = "0.5.3"
703
703
  source = { editable = "." }
704
704
  dependencies = [
705
705
  { name = "cryptography" },
File without changes
File without changes
File without changes
File without changes