From 3f7df82c580c673cf48d2b7c1429991a08428dee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sta=C5=9Bczak?= Date: Thu, 28 Dec 2023 01:35:41 +0100 Subject: [PATCH] Fix `digits` not being optional Fixes #77 (PR #78). * * * According to the https://github.com/google/google-authenticator/wiki/Key-Uri-Format#digits, `digits` parameter should be **optional**. It is not, e.g. after using this URI: ``` otpauth://totp/Example:alice@google.com?secret=JBSWY3DPEHPK3PXP&issuer=Example ``` The application raises this error: ``` [2023-12-22 18:36:00,369] DEBUG:otp:352: 1 validation error for Uri schema_ -> TOTPUriSchema -> parameters -> digits field required (type=value_error.missing) Usage: otp add uri [OPTIONS] ALIAS Try 'otp add uri -h' for help. Error: invalid URI ``` --- onetimepass/otpauth/schemas.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/onetimepass/otpauth/schemas.py b/onetimepass/otpauth/schemas.py index df808d4..9ccbc8f 100644 --- a/onetimepass/otpauth/schemas.py +++ b/onetimepass/otpauth/schemas.py @@ -19,7 +19,7 @@ class BaseUriParameters(BaseModel, extra=Extra.forbid): hash_algorithm: Literal["SHA1", "SHA256", "SHA512"] = Field( "SHA1", alias="algorithm" ) - digits: int + digits: int = 6 @validator("issuer") def issuer_must_match_pattern(cls, v):