Compare commits
4 Commits
8453ce7275
...
91c9b54762
Author | SHA1 | Date |
---|---|---|
Felipe M | 91c9b54762 | |
Felipe M | 752373bda1 | |
Felipe M | aef61caf06 | |
Felipe M | 6c4985dadb |
|
@ -19,4 +19,4 @@ repos:
|
|||
rev: stable
|
||||
hooks:
|
||||
- id: black
|
||||
language_version: python3.7
|
||||
language_version: python3
|
||||
|
|
|
@ -19,7 +19,7 @@ Right now it defaults to the `my` account, will be configurable in the future.
|
|||
usage: qute_1pass.py [-h] [--auto-submit] [--cache-session] command
|
||||
|
||||
positional arguments:
|
||||
command fill_credentials, fill_totp
|
||||
command fill_credentials, fill_totp, fill_username, fill_password
|
||||
|
||||
optional arguments:
|
||||
-h, --help show this help message and exit
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -8,14 +8,14 @@ authors = ["Felipe Martin <me@fmartingr.com>"]
|
|||
python = "^3.7"
|
||||
|
||||
[tool.poetry.dev-dependencies]
|
||||
black = {version = "^18.3-alpha.0", allows-prereleases = true}
|
||||
flake8 = "^3.7"
|
||||
isort = "^4.3"
|
||||
pre-commit = "^1.18"
|
||||
rope = "^0.14.0"
|
||||
ipdb = "^0.12.2"
|
||||
pylint = "^2.4"
|
||||
mypy = "^0.730.0"
|
||||
black = "*"
|
||||
flake8 = "*"
|
||||
isort = "*"
|
||||
pre-commit = "*"
|
||||
rope = "*"
|
||||
ipdb = "*"
|
||||
pylint = "*"
|
||||
mypy = "*"
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry>=0.12"]
|
||||
|
|
|
@ -36,7 +36,9 @@ CMD_OP_GET_TOTP = "op get totp {uuid} --session={session_id}"
|
|||
QUTE_FIFO = os.environ["QUTE_FIFO"]
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("command", help="fill_credentials, fill_totp")
|
||||
parser.add_argument(
|
||||
"command", help="fill_credentials, fill_totp, fill_username, fill_password"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--auto-submit", help="Auto submit after filling", action="store_true"
|
||||
)
|
||||
|
@ -82,6 +84,12 @@ class Qute:
|
|||
if submit:
|
||||
cls.fake_key("<Return>")
|
||||
|
||||
@classmethod
|
||||
def fill_single_field_tabmode(cls, value, submit=False):
|
||||
cls.fake_key(value)
|
||||
if submit:
|
||||
cls.fake_key("<Return>")
|
||||
|
||||
@classmethod
|
||||
def fill_totp(cls, totp, submit=True):
|
||||
cls.fake_key(totp)
|
||||
|
@ -226,7 +234,7 @@ class OnePass:
|
|||
)
|
||||
Qute.message_warning("Filled incomplete credentials")
|
||||
|
||||
return username, password
|
||||
return {"username": username, "password": password}
|
||||
|
||||
@classmethod
|
||||
def get_totp(cls, uuid):
|
||||
|
@ -259,18 +267,39 @@ class CLI:
|
|||
sys.exit(0)
|
||||
return item
|
||||
|
||||
def fill_credentials(self):
|
||||
item = self._get_item()
|
||||
username, password = OnePass.get_credentials(item)
|
||||
Qute.fill_credentials_tabmode(
|
||||
username, password, submit=self.arguments.auto_submit
|
||||
)
|
||||
# Store a reference to this items in case we need a quick reference to the UUID
|
||||
# to get the TOTP later
|
||||
def _store_last_item(self, item):
|
||||
"""
|
||||
Stores a reference to an item to easily get single information from it (password, TOTP)
|
||||
right after filling the username or credentials.
|
||||
"""
|
||||
last_item = {"host": extract_host(os.environ["QUTE_URL"]), "uuid": item["uuid"]}
|
||||
with open(LAST_ITEM_PATH, "w") as handler:
|
||||
handler.write(json.dumps(last_item))
|
||||
|
||||
def _fill_single_field(self, field):
|
||||
item = self._get_item()
|
||||
credentials = OnePass.get_credentials(item)
|
||||
Qute.fill_single_field_tabmode(
|
||||
credentials[field], submit=self.arguments.auto_submit
|
||||
)
|
||||
return item
|
||||
|
||||
def fill_username(self):
|
||||
item = self._fill_single_field("username")
|
||||
self._store_last_item(item)
|
||||
|
||||
def fill_password(self):
|
||||
item = self._fill_single_field("password")
|
||||
self._store_last_item(item)
|
||||
|
||||
def fill_credentials(self):
|
||||
item = self._get_item()
|
||||
credentials = OnePass.get_credentials(item)
|
||||
Qute.fill_credentials_tabmode(
|
||||
*credentials.values(), submit=self.arguments.auto_submit
|
||||
)
|
||||
self._store_last_item(item)
|
||||
|
||||
def fill_totp(self):
|
||||
# Check last item first
|
||||
# If theres a last_item file created in the last LAST_ITEM_DURATION seconds
|
||||
|
|
Loading…
Reference in New Issue