Handle missing issuers (from Gnome Authenticator) and add refs to Gnome

This commit is contained in:
Antonio J. Delgado 2023-09-22 09:42:43 +03:00
parent 54a2161004
commit a9c95ce234
4 changed files with 12 additions and 8 deletions

View file

@ -1,7 +1,7 @@
# andotp2freeotp
Convert the JSON backup of unmaintained andOTP app to a format readable by FreeOTP.
Current conversion to JSON format doesn't work since I have an math issue converting the andOTP secrets to FreeOTP ones.
Convert the JSON backup from Gnome Authenticator or the unmaintained andOTP app to a format readable by FreeOTP.
Current conversion to JSON format doesn't work since I have an math issue converting the secrets to FreeOTP ones.
See https://github.com/freeotp/freeotp-android/issues/368 and give me a hand with my math skills.
But URI format works as a charm.
@ -29,7 +29,7 @@ sudo python3 setup.py install
andotp2freeotp.py [--debug-level|-d CRITICAL|ERROR|WARNING|INFO|DEBUG|NOTSET] # Other parameters
-l, --log-file TEXT File to store all debug messages.
-i, --input TEXT JSON file from andOTP to convert [required]
-i, --input TEXT JSON file from andOTP or Gnome Authenticator to convert [required]
-o, --output TEXT JSON/URI file to write for FreeOTP [required]
-f, --format [uris|json] Format for the output. Either URIs or JSON. JSON doesn't work right now, pending on minor issue with conversion of secrets. See https://github.com/freeotp/freeotp-android/issues/368 and help me.
--config FILE Read configuration from FILE.

View file

@ -98,7 +98,10 @@ https://github.com/freeotp/freeotp-android/issues/368"""
self.uris = []
for item in self.data:
uri_type = item['type'].lower()
label = quote(f"{item['label']}@{item['issuer']}")
issuer = item.get('issuer', '')
if issuer == '' and 'tags' in item and len(item['tags']) > 0:
issuer = item['tags'][0]
label = quote(f"{item['label']}@{issuer}")
uri = f"otpauth://{uri_type}/{label}?secret={item['secret']}"
other_fields = [
'algorithm', 'digits', 'period', 'issuer', 'counter'
@ -172,7 +175,8 @@ https://github.com/freeotp/freeotp-android/issues/368"""
# @click.option("--dummy","-n", is_flag=True,
# help="Don't do anything, just show what would be done.")
@click.option(
'--input', '-i', required=True, help='JSON file from andOTP to convert'
'--input', '-i', required=True,
help='JSON file from andOTP or Gnome Authenticator to convert'
)
@click.option(
'--output', '-o', required=True, help='JSON/URI file to write for FreeOTP'

View file

@ -7,7 +7,7 @@ Homepage = ""
[project]
name = "andotp2freeotp"
version = "0.0.1"
version = "0.0.2"
description = "Convert andOTP json backups to FreeOTP format"
readme = "README.md"
authors = [{ name = "Antonio J. Delgado", email = "" }]
@ -22,4 +22,4 @@ dependencies = [
"click",
"click_config_file",
]
requires-python = ">=3"
requires-python = ">=3"

View file

@ -1,6 +1,6 @@
[metadata]
name = andotp2freeotp
version = 0.0.1
version = 0.0.2
[options]
packages = andotp2freeotp