Skip to content

Commit

Permalink
Refactor auth submodule
Browse files Browse the repository at this point in the history
  • Loading branch information
jotonedev committed Oct 1, 2024
1 parent 5829b21 commit e787c0a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
2 changes: 2 additions & 0 deletions pyown/auth/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
from .enum import *
from .hmac import *
from .open import *
15 changes: 15 additions & 0 deletions pyown/auth/enum.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from enum import IntEnum

from ..messages import GenericMessage

__all__ = [
"AuthAlgorithm",
]


class AuthAlgorithm(IntEnum):
SHA1 = 1
SHA256 = 2

def to_message(self) -> GenericMessage:
return GenericMessage(["98", str(self.value)])
12 changes: 1 addition & 11 deletions pyown/auth/hmac.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
from enum import IntEnum
from hashlib import sha1, sha256
from hmac import HMAC, compare_digest
from secrets import token_bytes

from ..messages.base import GenericMessage
from .enum import AuthAlgorithm

__all__ = [
"AuthAlgorithm",
"client_hmac",
"server_hmac",
"compare_hmac",
Expand All @@ -15,14 +13,6 @@
]


class AuthAlgorithm(IntEnum):
SHA1 = 1
SHA256 = 2

def to_message(self) -> GenericMessage:
return GenericMessage(["98", str(self.value)])


def client_hmac(
server_key: str,
client_key: str,
Expand Down

0 comments on commit e787c0a

Please sign in to comment.