jwbmisc 0.0.4__py3-none-any.whl → 0.0.5__py3-none-any.whl
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.
- jwbmisc/_version.py +2 -2
- jwbmisc/keeper.py +22 -21
- jwbmisc/passwd.py +2 -2
- {jwbmisc-0.0.4.dist-info → jwbmisc-0.0.5.dist-info}/METADATA +1 -1
- {jwbmisc-0.0.4.dist-info → jwbmisc-0.0.5.dist-info}/RECORD +8 -8
- {jwbmisc-0.0.4.dist-info → jwbmisc-0.0.5.dist-info}/WHEEL +0 -0
- {jwbmisc-0.0.4.dist-info → jwbmisc-0.0.5.dist-info}/licenses/LICENSE +0 -0
- {jwbmisc-0.0.4.dist-info → jwbmisc-0.0.5.dist-info}/top_level.txt +0 -0
jwbmisc/_version.py
CHANGED
|
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
|
|
|
28
28
|
commit_id: COMMIT_ID
|
|
29
29
|
__commit_id__: COMMIT_ID
|
|
30
30
|
|
|
31
|
-
__version__ = version = '0.0.
|
|
32
|
-
__version_tuple__ = version_tuple = (0, 0,
|
|
31
|
+
__version__ = version = '0.0.5'
|
|
32
|
+
__version_tuple__ = version_tuple = (0, 0, 5)
|
|
33
33
|
|
|
34
34
|
__commit_id__ = commit_id = None
|
jwbmisc/keeper.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import json
|
|
2
|
-
from keepercommander import vault
|
|
2
|
+
from keepercommander import vault
|
|
3
3
|
from keepercommander import api
|
|
4
4
|
from time import sleep
|
|
5
5
|
from keepercommander.params import KeeperParams
|
|
@@ -13,8 +13,10 @@ from logging import getLogger
|
|
|
13
13
|
|
|
14
14
|
logger = getLogger(__name__)
|
|
15
15
|
|
|
16
|
+
CONFIG_FILE = Path.home() / ".config" / "jwbmisc" / "keeper.json"
|
|
16
17
|
|
|
17
|
-
|
|
18
|
+
|
|
19
|
+
class MinimalKeeperUI:
|
|
18
20
|
def __init__(self):
|
|
19
21
|
self.waiting_for_sso_data_key = False
|
|
20
22
|
|
|
@@ -65,19 +67,19 @@ class _MinimalKeeperUI:
|
|
|
65
67
|
step.resume()
|
|
66
68
|
|
|
67
69
|
|
|
68
|
-
def
|
|
69
|
-
if isinstance(record,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
def extract_record_field(record, field: str) -> str | None:
|
|
71
|
+
if not isinstance(record, vault.TypedRecord):
|
|
72
|
+
raise TypeError("only TypedRecord is supported")
|
|
73
|
+
|
|
74
|
+
value = record.get_typed_field(field) or record.get_typed_field(None, field)
|
|
73
75
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
+
if value and value.value:
|
|
77
|
+
return value.value[0] if isinstance(value.value, list) else str(value.value)
|
|
76
78
|
|
|
77
79
|
return None
|
|
78
80
|
|
|
79
81
|
|
|
80
|
-
def
|
|
82
|
+
def perform_login(params):
|
|
81
83
|
if not params.user:
|
|
82
84
|
user = os.environ.get("KEEPER_USERNAME", None)
|
|
83
85
|
if user is None:
|
|
@@ -96,29 +98,28 @@ def _perform_keeper_login(params):
|
|
|
96
98
|
params.server = server
|
|
97
99
|
|
|
98
100
|
try:
|
|
99
|
-
api.login(params, login_ui=
|
|
101
|
+
api.login(params, login_ui=MinimalKeeperUI())
|
|
100
102
|
except KeyboardInterrupt:
|
|
101
103
|
raise KeyError("\nKeeper login cancelled by user.") from None
|
|
102
104
|
except Exception as e:
|
|
103
105
|
raise KeyError(f"Keeper login failed: {e}") from e
|
|
104
106
|
|
|
105
107
|
|
|
106
|
-
def
|
|
107
|
-
|
|
108
|
-
config_file.parent.mkdir(parents=True, exist_ok=True)
|
|
108
|
+
def get_password(record_uid: str, field_path: str) -> str:
|
|
109
|
+
CONFIG_FILE.parent.mkdir(parents=True, exist_ok=True)
|
|
109
110
|
|
|
110
|
-
params = KeeperParams(config_filename=str(
|
|
111
|
+
params = KeeperParams(config_filename=str(CONFIG_FILE))
|
|
111
112
|
|
|
112
|
-
if
|
|
113
|
+
if CONFIG_FILE.exists():
|
|
113
114
|
try:
|
|
114
|
-
params.config = json.loads(
|
|
115
|
+
params.config = json.loads(CONFIG_FILE.read_text())
|
|
115
116
|
loader.load_config_properties(params)
|
|
116
117
|
if not params.session_token:
|
|
117
118
|
raise ValueError("No session token")
|
|
118
119
|
except Exception:
|
|
119
|
-
|
|
120
|
+
perform_login(params)
|
|
120
121
|
else:
|
|
121
|
-
|
|
122
|
+
perform_login(params)
|
|
122
123
|
|
|
123
124
|
try:
|
|
124
125
|
api.sync_down(params)
|
|
@@ -126,11 +127,11 @@ def get_keeper_password(record_uid: str, field_path: str) -> str:
|
|
|
126
127
|
raise KeyError(f"Failed to sync Keeper vault: {e}") from e
|
|
127
128
|
|
|
128
129
|
try:
|
|
129
|
-
record =
|
|
130
|
+
record = vault.KeeperRecord.load(params, record_uid)
|
|
130
131
|
except Exception as e:
|
|
131
132
|
raise KeyError(f"Record {record_uid} not found: {e}") from e
|
|
132
133
|
|
|
133
|
-
value =
|
|
134
|
+
value = extract_record_field(record, field_path)
|
|
134
135
|
if value is None:
|
|
135
136
|
raise KeyError(f"Field '{field_path}' not found in record {record_uid}")
|
|
136
137
|
|
jwbmisc/passwd.py
CHANGED
|
@@ -72,6 +72,6 @@ def _call_unix_pass(key, lnum=1):
|
|
|
72
72
|
|
|
73
73
|
|
|
74
74
|
def _keeper_password(record_uid: str, field_path: str) -> str:
|
|
75
|
-
from .keeper import
|
|
75
|
+
from .keeper import get_password as keeper_get_password
|
|
76
76
|
|
|
77
|
-
return
|
|
77
|
+
return keeper_get_password(record_uid, field_path)
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
jwbmisc/__init__.py,sha256=5VXxKCMejjLWaiECh64309WJ2LpHHSULxaGOvCAOzyU,581
|
|
2
|
-
jwbmisc/_version.py,sha256=
|
|
2
|
+
jwbmisc/_version.py,sha256=YRV1ohn6CdKEhsUOmFFMmr5UTjMv4Ydw3WJGxF2BHBs,704
|
|
3
3
|
jwbmisc/collection.py,sha256=mICHxBFfk2XY8ajdWkLvmQF1R6oo6d0torpRAeDvd1c,663
|
|
4
4
|
jwbmisc/exec.py,sha256=9g1Jc7iDkBj1Y-dn5VhnwH1JqvWSbrFe6Mmvnf-iqag,1177
|
|
5
5
|
jwbmisc/fs.py,sha256=Vf28qbOnBeHEbXNMUZjOQXtMWBurjkzD2KmfV2gJQXM,599
|
|
6
6
|
jwbmisc/interactive.py,sha256=qMgpQNHvUg4AYw-aAAy2qdxri1aKr-mffoLfUgh8TWE,423
|
|
7
7
|
jwbmisc/json.py,sha256=h3CBDNNZjcTDxydViyydPsQufXQLuxqP24wBBAT2nDs,1198
|
|
8
|
-
jwbmisc/keeper.py,sha256=
|
|
9
|
-
jwbmisc/passwd.py,sha256=
|
|
8
|
+
jwbmisc/keeper.py,sha256=Fj9k8vWpfp2UMFiCfghWlnc5UxnkcR0oBQgY7NiJhsM,4241
|
|
9
|
+
jwbmisc/passwd.py,sha256=pTa0Lo7Qq10oo7PDlbq8lS3f5IaMFspKB27QI1NQB5k,2593
|
|
10
10
|
jwbmisc/string.py,sha256=0_AvtAyXUlyVL6yw1iMjs3vMunubTTTWS0PSu_qKgi8,1232
|
|
11
|
-
jwbmisc-0.0.
|
|
12
|
-
jwbmisc-0.0.
|
|
13
|
-
jwbmisc-0.0.
|
|
14
|
-
jwbmisc-0.0.
|
|
15
|
-
jwbmisc-0.0.
|
|
11
|
+
jwbmisc-0.0.5.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
12
|
+
jwbmisc-0.0.5.dist-info/METADATA,sha256=PEKl-YazmyJFlnl8uAYVHcpUhPbyUWp4L5ly1eEf_T4,14507
|
|
13
|
+
jwbmisc-0.0.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
14
|
+
jwbmisc-0.0.5.dist-info/top_level.txt,sha256=FqEYs8zdG3iGOJmC6cutDXfGQUNptzfYeKsaG43y1HE,8
|
|
15
|
+
jwbmisc-0.0.5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|