Skip to content

Commit

Permalink
v0.3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
rsrdesarrollo committed Oct 29, 2024
1 parent 928753f commit 3d059ea
Show file tree
Hide file tree
Showing 5 changed files with 370 additions and 15 deletions.
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
poetry 1.8.4
79 changes: 72 additions & 7 deletions moolticutepy/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,81 @@ def main(ctx: click.Context, debug: bool):

@main.command()
@pass_client
def list_logins(moolticuted: moolticutepy.MoolticuteClient):
@click.option(
"-o",
"--out-format",
required=False,
type=click.Choice(["json", "text"], case_sensitive=False),
default="text",
)
@click.option(
"--linked",
is_flag=True,
show_default=True,
default=False,
help="Show only linked accounts",
)
@click.option(
"--resolve-links",
is_flag=True,
show_default=True,
default=False,
help="Resolve links of accounts",
)
def list_logins(
moolticuted: moolticutepy.MoolticuteClient,
out_format: str,
linked: bool,
resolve_links: bool,
):
if out_format == "json" and resolve_links:
raise click.UsageError("Cannot use --resolve-links with json format")

try:
print("Entering management mode. Please approve prompt on device ...", end="")
print(
"Entering management mode. Please approve prompt on device ...",
end="",
file=sys.stderr,
)
sys.stderr.flush()
data = moolticuted.get_all_logins()
print("[OK]")
print("[OK]", file=sys.stderr)
sys.stderr.flush()

resolve_links_dict = dict()
if resolve_links:
for login in data:
service = login.service
for child in login.childs:
resolve_links_dict[str(child.address)] = dict(
service=service, login=child.login
)

if out_format == "text":
for login in data:

has_linked = any(
map(lambda child: child.pointed_to_child != [0, 0], login.childs)
)
if linked and not has_linked:
continue

print(f"- {login.service} [{login.multiple_domains}]:")
for child in login.childs:
if linked and child.pointed_to_child == [0, 0]:
continue

print(f"\t * {child.login}:")
for k, v in child.model_dump(exclude=["login"]).items():
if k == "pointed_to_child" and resolve_links:
resolved_pointer = resolve_links_dict[str(v)]
print(f"\t\t - {k}: {v} -> {resolved_pointer}")
else:
print(f"\t\t - {k}: {v}")
elif out_format == "json":
for login in data:
print(login.model_dump_json(exclude_none=False))

for login in data:
print(f"- {login.service} [{login.multiple_domains}]:")
for child in login.childs:
print(f"\t * {child.model_dump()}")
except moolticutepy.MoolticuteException as ex:
log.fatal(f"{ex}")

Expand Down
32 changes: 25 additions & 7 deletions moolticutepy/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,24 @@ class SetCredential(BaseRequest):
msg: Literal["set_credential"] = "set_credential"
data: SetCredentialData

class SetCredentialsData(BaseModel):
address: List[int]
category: int
description: Optional[str] = ""
favorite: Optional[int] = -1
key_after_login: Optional[int] = 65535
key_after_pwd: Optional[int] = 65535
login: str
multiple_domains: Optional[str] = "" # Coma list of tlds for example .com,.es
password: Optional[str] = "" # keep blank to keep current password
pointed_to_child: List[int]
service: str


class SetCredentials(BaseRequest): # Used in management mode tu update multiple credentials. Allows to link credentials
msg: Literal["set_credentials"] = "set_credentials"
data: SetCredentialsData


## RESPONSES
######################
Expand All @@ -71,20 +89,20 @@ class BaseResponse(BaseModel):


class MemoryManagementLoginNodeChild(BaseModel):
address: List[int] = Field(..., exclude=True)
address: List[int]
category: str
date_created: str
date_last_used: str
description: str
favorite: int
key_after_login: str = Field(..., exclude=True)
key_after_pwd: str = Field(..., exclude=True)
key_after_login: str
key_after_pwd: str
login: str
password_enc: List[int] = Field(..., exclude=True)
pointed_to_child: List[int] = Field(..., exclude=True)
pwd_blank_flag: str = Field(..., exclude=True)
totp_code_size: Optional[str] = Field(None, exclude=True)
totp_time_step: Optional[str] = Field(None, exclude=True)
pointed_to_child: List[int]
pwd_blank_flag: str
totp_code_size: Optional[str] = None
totp_time_step: Optional[str] = None


class MemoryManagementLoginNode(BaseModel):
Expand Down
Loading

0 comments on commit 3d059ea

Please sign in to comment.