refactor; rename classes and methods

This commit is contained in:
2025-03-10 09:26:55 -05:00
parent c1ca01eb93
commit 571268b86a
15 changed files with 160 additions and 160 deletions

View File

@@ -5,10 +5,10 @@ from typing import Dict, List, Tuple
from src.customer import Customer
from src.models import NKodePolicy, KeypadSize
from src.user import User
from src.user_cipher_keys import UserCipherKeys
from src.user_cipher_keys import UserCipher
from src.user_signup_session import UserSignupSession
from src.user_keypad import UserKeypad
from src.customer_attributes import CustomerAttributes
from src.customer_cipher import CustomerCipher
@dataclass
@@ -19,7 +19,7 @@ class NKodeAPI:
def create_new_customer(self, keypad_size: KeypadSize, nkode_policy: NKodePolicy) -> UUID:
new_customer = Customer(
customer_id=uuid4(),
attributes=CustomerAttributes.create(keypad_size),
customer_cipher=CustomerCipher.create(keypad_size),
users={},
nkode_policy=nkode_policy
)
@@ -30,7 +30,7 @@ class NKodeAPI:
if customer_id not in self.customers.keys():
raise ValueError(f"Customer with ID '{customer_id}' does not exist")
customer = self.customers[customer_id]
login_keypad = UserKeypad.create(customer.attributes.keypad_size)
login_keypad = UserKeypad.create(customer.customer_cipher.keypad_size)
set_keypad = login_keypad.sign_up_keypad()
new_session = UserSignupSession(
session_id=uuid4(),
@@ -75,12 +75,12 @@ class NKodeAPI:
raise AssertionError(f"Username mismatch: {username} vs {session.username}")
customer = self.customers[customer_id]
passcode = self.signup_sessions[session_id].deduce_passcode(confirm_key_entry)
new_user_keys = UserCipherKeys.create(
customer.attributes.keypad_size,
customer.attributes.set_vals,
new_user_keys = UserCipher.create(
customer.customer_cipher.keypad_size,
customer.customer_cipher.set_key,
customer.nkode_policy.max_nkode_len
)
enciphered_passcode = new_user_keys.encipher_nkode(passcode, customer.attributes)
enciphered_passcode = new_user_keys.encipher_nkode(passcode, customer.customer_cipher)
new_user = User(
username=username,
enciphered_passcode=enciphered_passcode,