bitwarden-wrapper 0.1.0__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.
- bitwarden_wrapper/__init__.py +422 -0
- bitwarden_wrapper/tui/bitwarden.css +81 -0
- bitwarden_wrapper/tui/bitwarden_app.py +78 -0
- bitwarden_wrapper/tui/bitwarden_credentials_modal_screen.py +119 -0
- bitwarden_wrapper/tui/bitwarden_existing_item.tcss +109 -0
- bitwarden_wrapper/tui/bitwarden_existing_item_app.py +169 -0
- bitwarden_wrapper-0.1.0.dist-info/METADATA +61 -0
- bitwarden_wrapper-0.1.0.dist-info/RECORD +10 -0
- bitwarden_wrapper-0.1.0.dist-info/WHEEL +4 -0
- bitwarden_wrapper-0.1.0.dist-info/licenses/LICENSE +660 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
$bluish_white: rgb(189,216,255);
|
|
2
|
+
$lavender: rgb(174,168,248);
|
|
3
|
+
$spacechalk_red: rgb(255,141,135);
|
|
4
|
+
$neon_magenta: rgb(242,137,249);
|
|
5
|
+
$light_pink: rgb(255,175,249);
|
|
6
|
+
$orange: rgb(253,205,54);
|
|
7
|
+
$soft_yellow: rgb(249,249,134);
|
|
8
|
+
$soft_green: rgb(193,255,135);
|
|
9
|
+
$spacechalk_lime: rgb(168,253,87);
|
|
10
|
+
$sky_blue: rgb(92,201,253);
|
|
11
|
+
$cornflower: rgb(95,135,255);
|
|
12
|
+
$light_cornflower: rgb(122,162,247);
|
|
13
|
+
$blue_gray: rgb(86,95,137);
|
|
14
|
+
$dark_gray: rgb(58,58,58);
|
|
15
|
+
$navy: rgb(35,35,54);
|
|
16
|
+
|
|
17
|
+
/* Matches the entire screen */
|
|
18
|
+
Screen {
|
|
19
|
+
align: center middle;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
Tooltip {
|
|
23
|
+
background: $navy 50%;
|
|
24
|
+
color: $bluish_white 75%;
|
|
25
|
+
border: dashed gray 80%;
|
|
26
|
+
padding-bottom: 0;
|
|
27
|
+
padding-left: 1;
|
|
28
|
+
padding-right: 1;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
Button {
|
|
32
|
+
color: $light_cornflower;
|
|
33
|
+
background: $lavender 10%;
|
|
34
|
+
border-top: tall $blue_gray 60%;
|
|
35
|
+
border-bottom: tall $dark_gray 50%;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
Label {
|
|
39
|
+
color: $lavender;
|
|
40
|
+
width: 100%;
|
|
41
|
+
content-align: center middle;
|
|
42
|
+
margin-top: 2;
|
|
43
|
+
height: 3;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/* select an item to view/edit radioset */
|
|
47
|
+
RadioSet {
|
|
48
|
+
height: auto;
|
|
49
|
+
padding-top: 1;
|
|
50
|
+
padding-bottom: 1;
|
|
51
|
+
align: center middle;
|
|
52
|
+
content-align: center middle;
|
|
53
|
+
width: 100%;
|
|
54
|
+
color: $bluish_white;
|
|
55
|
+
margin-bottom: 1;
|
|
56
|
+
border: solid $light_cornflower;
|
|
57
|
+
border-title-color: $sky_blue;
|
|
58
|
+
background: $navy;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/* whole screen grid */
|
|
62
|
+
#main-screen-grid {
|
|
63
|
+
border: solid $cornflower;
|
|
64
|
+
border-title-color: $sky_blue;
|
|
65
|
+
width: 80%;
|
|
66
|
+
height: 85%;
|
|
67
|
+
padding: 1;
|
|
68
|
+
grid-rows: 0.8fr 0.6fr 0.15fr;
|
|
69
|
+
align: center middle;
|
|
70
|
+
background: $navy 50%;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/* includes both the selection list, if exists, and the actual vault item */
|
|
74
|
+
#all-duplicates-view {
|
|
75
|
+
align: center middle;
|
|
76
|
+
padding-top: 1;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/* the vault item preview */
|
|
80
|
+
#pretty-scroll {
|
|
81
|
+
border: solid $blue_gray;
|
|
82
|
+
border-title-color: $sky_blue;
|
|
83
|
+
scrollbar-background: $dark_gray;
|
|
84
|
+
scrollbar-background-active: $dark_gray;
|
|
85
|
+
scrollbar-background-hover: $dark_gray;
|
|
86
|
+
scrollbar-color-active: $sky_blue;
|
|
87
|
+
scrollbar-color-hover: $cornflower;
|
|
88
|
+
scrollbar-color: $light_cornflower;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
#question-box {
|
|
92
|
+
grid-gutter: 1;
|
|
93
|
+
grid-rows: 0.25fr 0.25fr 0.5fr;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/* just the three option buttons */
|
|
97
|
+
#button-grid {
|
|
98
|
+
height: 5;
|
|
99
|
+
grid-size: 3;
|
|
100
|
+
align: center middle;
|
|
101
|
+
content-align: center middle;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
#always-checkbox {
|
|
105
|
+
width: 100%;
|
|
106
|
+
content-align: center middle;
|
|
107
|
+
background: $navy 1%;
|
|
108
|
+
color: $bluish_white;
|
|
109
|
+
}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
from textual.app import App, ComposeResult
|
|
2
|
+
from textual.containers import Grid, VerticalScroll, Container
|
|
3
|
+
from textual.widgets import Label, Pretty, Checkbox, Button, RadioSet, RadioButton
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class AskUserForDuplicateStrategy(App[None]):
|
|
7
|
+
"""
|
|
8
|
+
ask user how to handle creating an item when duplicate[s] found
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
CSS_PATH = ["./bitwarden_existing_item.tcss"]
|
|
12
|
+
|
|
13
|
+
def __init__(self, duplicate_item: dict | list, item_searched: str) -> None:
|
|
14
|
+
self.duplicate_item = duplicate_item
|
|
15
|
+
self.item_searched = item_searched
|
|
16
|
+
self.always_do = False
|
|
17
|
+
super().__init__()
|
|
18
|
+
|
|
19
|
+
def compose(self) -> ComposeResult:
|
|
20
|
+
"""
|
|
21
|
+
check if we need to grab the password or not
|
|
22
|
+
"""
|
|
23
|
+
with Grid(id="main-screen-grid"):
|
|
24
|
+
with Container(id="all-duplicates-view"):
|
|
25
|
+
if isinstance(self.duplicate_item, list):
|
|
26
|
+
with RadioSet():
|
|
27
|
+
for item in self.duplicate_item:
|
|
28
|
+
button = RadioButton(item['id'])
|
|
29
|
+
# set the radio button to be a heart :3
|
|
30
|
+
button.BUTTON_INNER = "♥ "
|
|
31
|
+
yield button
|
|
32
|
+
with VerticalScroll(id="pretty-scroll"):
|
|
33
|
+
yield Pretty("Select an item above to preview")
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
with Grid(id="question-box"):
|
|
37
|
+
yield Label("How would you like to proceed?")
|
|
38
|
+
check_box = Checkbox("Always perform this action",
|
|
39
|
+
id="always-checkbox")
|
|
40
|
+
yield check_box
|
|
41
|
+
|
|
42
|
+
with Grid(id="button-grid"):
|
|
43
|
+
edit_button = Button("✏️ Edit", id="edit-button")
|
|
44
|
+
edit_button.tooltip = "Edit the existing Vault item with new info"
|
|
45
|
+
yield edit_button
|
|
46
|
+
|
|
47
|
+
duplicate_button = Button("👥 Duplicate", id="duplicate-button")
|
|
48
|
+
duplicate_button.tooltip = "Create an additional Vault item"
|
|
49
|
+
yield duplicate_button
|
|
50
|
+
|
|
51
|
+
no_action_button = Button("⛔️ No Action", id="no-action-button")
|
|
52
|
+
no_action_button.tooltip = "Use the existing Vault item"
|
|
53
|
+
yield no_action_button
|
|
54
|
+
|
|
55
|
+
def on_mount(self) -> None:
|
|
56
|
+
"""
|
|
57
|
+
border styling and enabling of the edit button
|
|
58
|
+
"""
|
|
59
|
+
pretty_scroll = self.get_widget_by_id("pretty-scroll")
|
|
60
|
+
pretty_scroll.border_title = "Bitarden Vault Item [#C1FF87]Preview[/]"
|
|
61
|
+
if isinstance(self.duplicate_item, list):
|
|
62
|
+
box_title = ('[#ffaff9][i]duplicate[/i] items[/] found for '
|
|
63
|
+
f'[#C2FF87]{self.item_searched}[/] in your vault')
|
|
64
|
+
|
|
65
|
+
# disable the edit button till a user has selected an item
|
|
66
|
+
edit_button = self.get_widget_by_id("edit-button")
|
|
67
|
+
edit_button.disabled = True
|
|
68
|
+
edit_button.tooltip = ("Select an item above to have smol-k8s-lab "
|
|
69
|
+
"edit the existing item in your Vault.")
|
|
70
|
+
|
|
71
|
+
self.query_one(RadioSet).border_title = (
|
|
72
|
+
"[#ffaff9]♥[/] [i]select[/] an item to view/edit")
|
|
73
|
+
else:
|
|
74
|
+
self.query_one(Pretty).update(self.duplicate_item)
|
|
75
|
+
box_title = (
|
|
76
|
+
"An [#ffaff9][i]existing[/i] item[/] for "
|
|
77
|
+
f"[#C1FF87]{self.item_searched}[/] found in your vault"
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
self.get_widget_by_id("main-screen-grid").border_title = box_title
|
|
81
|
+
|
|
82
|
+
def on_check_box_ticked(self, event: Checkbox.Changed) -> None:
|
|
83
|
+
"""
|
|
84
|
+
if the checkbox is selected, we update the self.always_do variable
|
|
85
|
+
"""
|
|
86
|
+
self.always_do = event.checkbox.value
|
|
87
|
+
|
|
88
|
+
def on_radio_set_changed(self, event: RadioSet.Changed) -> None:
|
|
89
|
+
"""
|
|
90
|
+
if any radio set button is selected, update the Pretty widget and
|
|
91
|
+
make sure the edit button is enabled again
|
|
92
|
+
"""
|
|
93
|
+
pressed_index = event.radio_set.pressed_index
|
|
94
|
+
self.query_one(Pretty).update(self.duplicate_item[pressed_index])
|
|
95
|
+
self.get_widget_by_id("edit-button").disabled = False
|
|
96
|
+
|
|
97
|
+
def on_button_pressed(self, event: Button.Pressed) -> None:
|
|
98
|
+
"""
|
|
99
|
+
if any button is pressed, take action and exit
|
|
100
|
+
"""
|
|
101
|
+
if isinstance(self.duplicate_item, list):
|
|
102
|
+
item = self.duplicate_item[self.query_one(RadioSet).pressed_index]
|
|
103
|
+
else:
|
|
104
|
+
item = self.duplicate_item
|
|
105
|
+
|
|
106
|
+
if event.button.id == "no-action-button":
|
|
107
|
+
self.app.exit(["no_action", self.always_do, item])
|
|
108
|
+
|
|
109
|
+
if event.button.id == "edit-button":
|
|
110
|
+
self.app.exit(["edit", self.always_do, item])
|
|
111
|
+
|
|
112
|
+
if event.button.id == "duplicate-button":
|
|
113
|
+
self.app.exit(["duplicate", self.always_do, item])
|
|
114
|
+
|
|
115
|
+
# for testing only
|
|
116
|
+
if __name__ == "__main__":
|
|
117
|
+
item = {"creationDate": "2022-03-19T12:22:02.920Z",
|
|
118
|
+
"id": "2222224b-u94j-rv85-8787-y5555555555o",
|
|
119
|
+
"organizationId": None,
|
|
120
|
+
"folderId": "33333333-c5l8-328a-ge49-ve0000000000",
|
|
121
|
+
"name": "www.bol.com",
|
|
122
|
+
"notes": None,
|
|
123
|
+
"favorite": False,
|
|
124
|
+
"login": {
|
|
125
|
+
"uris": [
|
|
126
|
+
{"match": None,
|
|
127
|
+
"uri": "https://www.test.com/"}
|
|
128
|
+
],
|
|
129
|
+
"username": "test@test.test",
|
|
130
|
+
"password": "passwordthatissupposedtobesecurebutisnot",
|
|
131
|
+
"passwordRevisionDate": None}
|
|
132
|
+
}
|
|
133
|
+
item_list = [
|
|
134
|
+
{"creationDate": "2022-02-19T12:22:02.920Z",
|
|
135
|
+
"id": "2222224b-u94j-rv85-8787-y5555555555o",
|
|
136
|
+
"organizationId": None,
|
|
137
|
+
"folderId": "33333333-c5l8-328a-ge49-ve0000000000",
|
|
138
|
+
"name": "www.bol.com",
|
|
139
|
+
"notes": None,
|
|
140
|
+
"favorite": False,
|
|
141
|
+
"login": {
|
|
142
|
+
"uris": [
|
|
143
|
+
{"match": None,
|
|
144
|
+
"uri": "https://www.test.com/"}
|
|
145
|
+
],
|
|
146
|
+
"username": "test@test.test",
|
|
147
|
+
"password": "passwordthatissupposedtobesecure",
|
|
148
|
+
"passwordRevisionDate": None}
|
|
149
|
+
},
|
|
150
|
+
{"creationDate": "2023-02-19T12:22:02.920Z",
|
|
151
|
+
"id": "2247q311-b06a-ww85-9532-a00000bb548f",
|
|
152
|
+
"organizationId": None,
|
|
153
|
+
"folderId": "33333333-c5l8-328a-ge49-ve0000000000",
|
|
154
|
+
"name": "www.bol.com",
|
|
155
|
+
"notes": None,
|
|
156
|
+
"favorite": False,
|
|
157
|
+
"login": {
|
|
158
|
+
"uris": [
|
|
159
|
+
{"match": None,
|
|
160
|
+
"uri": "https://www.test.com/"}
|
|
161
|
+
],
|
|
162
|
+
"username": "test@test.test",
|
|
163
|
+
"password": "supposedtobesecurebutisnot",
|
|
164
|
+
"passwordRevisionDate": None}
|
|
165
|
+
}
|
|
166
|
+
]
|
|
167
|
+
app = AskUserForDuplicateStrategy(item,
|
|
168
|
+
"argocd-admin-credentials-argo.test.com")
|
|
169
|
+
app.run()
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: bitwarden-wrapper
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Simple bitwarden cli wrapper that can get and create credentials.
|
|
5
|
+
License-Expression: AGPL-3.0-or-later
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Keywords: bitwarden,passwordmanager
|
|
8
|
+
Requires-Python: >=3.13,<3.15
|
|
9
|
+
Classifier: Development Status :: 4 - Beta
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
12
|
+
Classifier: Operating System :: MacOS :: MacOS X
|
|
13
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
14
|
+
Classifier: License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)
|
|
15
|
+
Requires-Dist: rich (>=14.1,<15.0)
|
|
16
|
+
Requires-Dist: rich-subproc (>=0.1.0,<0.2.0)
|
|
17
|
+
Requires-Dist: textual (>=8.0,<9.0)
|
|
18
|
+
Project-URL: Bug Tracker, http://codeberg.org/open-engineering/bitwarden-wrapper/issues
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
|
|
21
|
+
# bitwarden-wrapper
|
|
22
|
+
|
|
23
|
+
<a href="https://pypi.org/project/bitwarden-wrapper/">
|
|
24
|
+
<img alt="PyPI - Version" src="https://img.shields.io/pypi/v/bitwarden-wrapper?logo=pypi">
|
|
25
|
+
</a>
|
|
26
|
+
|
|
27
|
+
An extremely simple Bitwarden CLI wrapper. Originally developed for [smol-k8s-lab](https://smol-k8s-lab.open.engineering), but extracted so it can be used elsewhere.
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
Here's the basic usage:
|
|
32
|
+
|
|
33
|
+
```python
|
|
34
|
+
# initialize the object
|
|
35
|
+
bw = BwCLI(my_passsword, my_client_id, my_client_secret)
|
|
36
|
+
|
|
37
|
+
# unlock the vault
|
|
38
|
+
bw.unlock()
|
|
39
|
+
|
|
40
|
+
# generate a random password
|
|
41
|
+
random_password = bw.generate()
|
|
42
|
+
# create a login item in the vault
|
|
43
|
+
bw.create_login(name="test mctest",
|
|
44
|
+
item_url="coolhosting4dogs.tech",
|
|
45
|
+
user="admin",
|
|
46
|
+
password=random_password)
|
|
47
|
+
|
|
48
|
+
# lock the vault
|
|
49
|
+
bw.lock()
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
If you pass in `tui=True` to the `BwCLI` object, we'll also display a TUI for when a duplicate item exists to allow the user to select what they'd like to do.
|
|
53
|
+
|
|
54
|
+
You can also specify `duplicate_strategy="edit"` to edit existing items. The values for `duplicate_strategy` can be: "edit", "ask", "duplicate", "no_action", but it always defaults to "ask".
|
|
55
|
+
|
|
56
|
+
## Warnings
|
|
57
|
+
|
|
58
|
+
1. If you set your logging library to log level DEBUG, we may print sensitive info when creating and deleting vault items. This is intensional *for debugging purposes only*.
|
|
59
|
+
|
|
60
|
+
2. The TUI may throw issues when run inside an event loop. In which case, wecan always fall back to using rich instead.
|
|
61
|
+
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
bitwarden_wrapper/__init__.py,sha256=NzwiGm7EUbpuvdyAn16vDoGQ4PtJvD0NbH8HBp7VW4E,15948
|
|
2
|
+
bitwarden_wrapper/tui/bitwarden.css,sha256=lTAyozYI5zFMe1WUs4GzKqTdVMUrrDvBgC_JhCFE62k,1679
|
|
3
|
+
bitwarden_wrapper/tui/bitwarden_app.py,sha256=r99KQRoyOo_WNAzcIEwz2FS8gJHF0vd3hsg5nh81dpc,2093
|
|
4
|
+
bitwarden_wrapper/tui/bitwarden_credentials_modal_screen.py,sha256=v6JzfUGnZSYleS4c11nF2bOqnWSZG5po0_Ol06dgVbk,4569
|
|
5
|
+
bitwarden_wrapper/tui/bitwarden_existing_item.tcss,sha256=tk9M-Sa_20Xbb4hQTwWlq0L2ck1rtm9yQcZ8hUbOjNg,2395
|
|
6
|
+
bitwarden_wrapper/tui/bitwarden_existing_item_app.py,sha256=VojxNJjJOMJ1DFTr0BZY432zDtZHmWDlkmlMDJEADW0,6914
|
|
7
|
+
bitwarden_wrapper-0.1.0.dist-info/METADATA,sha256=zJUvIZkJWtoSfM0wcRyCxF3ufXn7rzmkuMjz0JLud4Y,2290
|
|
8
|
+
bitwarden_wrapper-0.1.0.dist-info/WHEEL,sha256=EGEvSphFYqXKs23-kQBeyNoJP1nrT8ZJKQoi5p5DYL8,88
|
|
9
|
+
bitwarden_wrapper-0.1.0.dist-info/licenses/LICENSE,sha256=ADUqsZhl4juwq34PRTMiBqumpm11s_PMli_dZQjWPqQ,34260
|
|
10
|
+
bitwarden_wrapper-0.1.0.dist-info/RECORD,,
|