diff --git a/pass_import/clean.py b/pass_import/clean.py index 7509a55..114e9e2 100644 --- a/pass_import/clean.py +++ b/pass_import/clean.py @@ -142,3 +142,14 @@ def duplicate(data: List[Dict[str, str]]): entry['path'] = path else: seen.add(path) + + +def otp(data: List[Dict[str, str]]): + """Format the otpauth url with sane default.""" + for entry in data: + if 'otpauth' in entry: + if not entry['otpauth'].startswith('otpauth://'): + secret = entry['otpauth'] + otp = f"otpauth://totp/{entry.get('title', 'otp-secret')}" + otp += f"?secret={secret}" + entry['otpauth'] = otp diff --git a/pass_import/manager.py b/pass_import/manager.py index 5d519e8..45e00dc 100644 --- a/pass_import/manager.py +++ b/pass_import/manager.py @@ -148,6 +148,7 @@ def clean(self, cmdclean: bool, convert: bool): 2. Clean the protocol's name in the title. 3. Clean group from unwanted values in Unix or Windows paths. 4. Duplicate paths. + 5. Format the One-Time Password (OTP) url. :param bool cmdclean: If ``True``, make the paths more command line friendly. @@ -163,6 +164,7 @@ def clean(self, cmdclean: bool, convert: bool): clean.dpaths(self.data, cmdclean, convert) clean.dpaths(self.data, cmdclean, convert) clean.duplicate(self.data) + clean.otp(self.data) def audit(self, hibp: bool = False): """Audit the parsed password for vulnerable passwords.