diff --git a/selfprivacy_api/actions/api_tokens.py b/selfprivacy_api/actions/api_tokens.py index 03de653..a90aa12 100644 --- a/selfprivacy_api/actions/api_tokens.py +++ b/selfprivacy_api/actions/api_tokens.py @@ -110,3 +110,7 @@ def get_new_api_recovery_key( key = TOKEN_REPO.create_recovery_key(expiration_date, uses_left) mnemonic_phrase = Mnemonic(language="english").to_mnemonic(bytes.fromhex(key.key)) return mnemonic_phrase + + +def delete_new_device_auth_token() -> None: + TOKEN_REPO.delete_new_device_key() diff --git a/selfprivacy_api/graphql/mutations/api_mutations.py b/selfprivacy_api/graphql/mutations/api_mutations.py index 9f04317..0c83eab 100644 --- a/selfprivacy_api/graphql/mutations/api_mutations.py +++ b/selfprivacy_api/graphql/mutations/api_mutations.py @@ -12,6 +12,7 @@ from selfprivacy_api.actions.api_tokens import ( delete_api_token, get_new_api_recovery_key, refresh_api_token, + delete_new_device_auth_token, ) from selfprivacy_api.graphql import IsAuthenticated from selfprivacy_api.graphql.mutations.mutation_interface import ( @@ -20,7 +21,6 @@ from selfprivacy_api.graphql.mutations.mutation_interface import ( ) from selfprivacy_api.utils.auth import ( - delete_new_device_auth_token, get_new_device_auth_token, use_new_device_auth_token, ) diff --git a/selfprivacy_api/rest/api_auth.py b/selfprivacy_api/rest/api_auth.py index f73056c..8209ef6 100644 --- a/selfprivacy_api/rest/api_auth.py +++ b/selfprivacy_api/rest/api_auth.py @@ -12,12 +12,12 @@ from selfprivacy_api.actions.api_tokens import ( get_api_tokens_with_caller_flag, get_new_api_recovery_key, refresh_api_token, + delete_new_device_auth_token, ) from selfprivacy_api.dependencies import TokenHeader, get_token_header from selfprivacy_api.utils.auth import ( - delete_new_device_auth_token, get_new_device_auth_token, use_mnemonic_recoverery_token, use_new_device_auth_token, diff --git a/selfprivacy_api/utils/auth.py b/selfprivacy_api/utils/auth.py index 3383f8d..847cd30 100644 --- a/selfprivacy_api/utils/auth.py +++ b/selfprivacy_api/utils/auth.py @@ -257,13 +257,6 @@ def _get_new_device_auth_token(): return new_device["token"] -def delete_new_device_auth_token(): - """Delete new device auth token""" - with WriteUserData(UserDataFiles.TOKENS) as tokens: - if "new_device" in tokens: - del tokens["new_device"] - - def use_new_device_auth_token(mnemonic_phrase, name): """Use the new device auth token by converting the mnemonic string to a byte array. If the mnemonic phrase is valid then generate a device token and return it.