passphera-core 0.13.0__py3-none-any.whl → 0.14.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,4 @@
1
1
  from datetime import datetime, timezone
2
- from uuid import UUID
3
2
 
4
3
  from passphera_core.entities import Generator
5
4
  from passphera_core.interfaces import GeneratorRepository
@@ -26,32 +25,35 @@ class UpdateGeneratorPropertyUseCase:
26
25
  def __init__(self, generator_repository: GeneratorRepository):
27
26
  self.generator_repository: GeneratorRepository = generator_repository
28
27
 
29
- def execute(self, field: str, value: str) -> None:
28
+ def execute(self, field: str, value: str) -> Generator:
30
29
  generator_entity: Generator = self.generator_repository.get()
31
30
  setattr(generator_entity, field, value)
32
31
  if field == 'algorithm':
33
32
  generator_entity.get_algorithm()
34
33
  generator_entity.updated_at = datetime.now(timezone.utc)
35
34
  self.generator_repository.update(generator_entity)
35
+ return generator_entity
36
36
 
37
37
 
38
38
  class AddCharacterReplacementUseCase:
39
39
  def __init__(self, generator_repository: GeneratorRepository):
40
40
  self.generator_repository: GeneratorRepository = generator_repository
41
41
 
42
- def execute(self, character: str, replacement: str) -> None:
42
+ def execute(self, character: str, replacement: str) -> Generator:
43
43
  generator_entity: Generator = self.generator_repository.get()
44
44
  generator_entity.replace_character(character, replacement)
45
45
  generator_entity.updated_at = datetime.now(timezone.utc)
46
46
  self.generator_repository.update(generator_entity)
47
+ return generator_entity
47
48
 
48
49
 
49
50
  class ResetCharacterReplacementUseCase:
50
51
  def __init__(self, generator_repository: GeneratorRepository,):
51
52
  self.generator_repository: GeneratorRepository = generator_repository
52
53
 
53
- def execute(self, character: str) -> None:
54
+ def execute(self, character: str) -> Generator:
54
55
  generator_entity: Generator = self.generator_repository.get()
55
56
  generator_entity.reset_character(character)
56
57
  generator_entity.updated_at = datetime.now(timezone.utc)
57
58
  self.generator_repository.update(generator_entity)
59
+ return generator_entity
@@ -1,4 +1,4 @@
1
- from uuid import UUID
1
+ from datetime import datetime, timezone
2
2
 
3
3
  from passphera_core.entities import Password, Generator
4
4
  from passphera_core.exceptions import DuplicatePasswordException, PasswordNotFoundException
@@ -14,11 +14,11 @@ class GeneratePasswordUseCase:
14
14
  self.password_repository: PasswordRepository = password_repository
15
15
  self.generator_repository: GeneratorRepository = generator_repository
16
16
 
17
- def execute(self, generator_id: UUID, context: str, text: str) -> Password:
17
+ def execute(self, context: str, text: str) -> Password:
18
18
  password_entity: Password = self.password_repository.get_by_context(context)
19
19
  if password_entity and password_entity.deleted_at is not None:
20
20
  raise DuplicatePasswordException(password_entity)
21
- generator_entity: Generator = self.generator_repository.get(generator_id)
21
+ generator_entity: Generator = self.generator_repository.get()
22
22
  password: str = generator_entity.generate_password(text)
23
23
  password_entity: Password = Password(context=context, text=text, password=password)
24
24
  password_entity.encrypt()
@@ -32,7 +32,7 @@ class GetPasswordByContextUseCase:
32
32
 
33
33
  def execute(self, context: str) -> Password:
34
34
  password_entity: Password = self.password_repository.get_by_context(context)
35
- if not password_entity:
35
+ if not password_entity or password_entity.deleted_at is not None:
36
36
  raise PasswordNotFoundException()
37
37
  return password_entity
38
38
 
@@ -46,14 +46,15 @@ class UpdatePasswordUseCase:
46
46
  self.password_repository: PasswordRepository = password_repository
47
47
  self.generator_repository: GeneratorRepository = generator_repository
48
48
 
49
- def execute(self, generator_id: UUID, context: str, text: str) -> Password:
49
+ def execute(self, context: str, text: str) -> Password:
50
50
  password_entity: Password = self.password_repository.get_by_context(context)
51
- if not password_entity:
51
+ if not password_entity or password_entity.deleted_at is not None:
52
52
  raise PasswordNotFoundException()
53
- generator_entity: Generator = self.generator_repository.get(generator_id)
53
+ generator_entity: Generator = self.generator_repository.get()
54
54
  password: str = generator_entity.generate_password(text)
55
55
  password_entity.text = text
56
56
  password_entity.password = password
57
+ password_entity.updated_at = datetime.now(timezone.utc)
57
58
  password_entity.encrypt()
58
59
  self.password_repository.update(password_entity)
59
60
  return password_entity
@@ -65,8 +66,9 @@ class DeletePasswordUseCase:
65
66
 
66
67
  def execute(self, context: str) -> None:
67
68
  password_entity: Password = self.password_repository.get_by_context(context)
68
- if not password_entity:
69
+ if not password_entity or password_entity.deleted_at is not None:
69
70
  raise PasswordNotFoundException()
71
+ password_entity.deleted_at = datetime.now(timezone.utc)
70
72
  self.password_repository.delete(password_entity)
71
73
 
72
74
 
@@ -14,7 +14,7 @@ class Password:
14
14
  id: UUID = field(default_factory=uuid4)
15
15
  created_at: datetime = field(default_factory=lambda: datetime.now(timezone.utc))
16
16
  updated_at: datetime = field(default_factory=lambda: datetime.now(timezone.utc))
17
- deleted_at: datetime = field(default_factory=lambda: datetime.now(timezone.utc))
17
+ deleted_at: datetime = field(default=None)
18
18
  context: str = field(default_factory=str)
19
19
  text: str = field(default_factory=str)
20
20
  password: str = field(default_factory=str)
@@ -82,8 +82,7 @@ class Generator:
82
82
  :param password: The password to perform the action on it
83
83
  :return: str: The new ciphered password after character replacements
84
84
  """
85
- translation_table: dict[int, str] = str.maketrans(self.characters_replacements)
86
- return password.translate(translation_table)
85
+ return password.translate(str.maketrans(self.characters_replacements))
87
86
 
88
87
  def generate_password(self, text: str) -> str:
89
88
  """
@@ -1,5 +1,4 @@
1
1
  from abc import ABC, abstractmethod
2
- from uuid import UUID
3
2
 
4
3
  from passphera_core.entities import Password, Generator
5
4
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: passphera-core
3
- Version: 0.13.0
3
+ Version: 0.14.0
4
4
  Summary: The core system of passphera project
5
5
  Home-page: https://github.com/passphera/core
6
6
  Author: Fathi Abdelmalek
@@ -0,0 +1,11 @@
1
+ passphera_core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ passphera_core/entities.py,sha256=ff7CbWBjqxb2Z6jZZMFoaSzISazLO3cjESi5hbVjp9E,4226
3
+ passphera_core/exceptions.py,sha256=Xir2lYIH7QYHfjDQu8WJ9qIhCvP-mYcPWYN2LbbbDj8,640
4
+ passphera_core/interfaces.py,sha256=zk-9X28Vful3bdZO5q4crsl06AFmI6N9cdGu0UfuEws,869
5
+ passphera_core/application/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ passphera_core/application/generator.py,sha256=UKsukvpItbq2Vn3XZSZf8Iwr1WPmDFYP7i14R_Hp9pU,2420
7
+ passphera_core/application/password.py,sha256=bG1lafpeyFN7jkxXzxq10zSngXtfrvKR7UFQRB2jLas,3747
8
+ passphera_core-0.14.0.dist-info/METADATA,sha256=furJ8GhcwtSCCMYFn_OfTisf6fnEqOMnYszKOg-fIJU,868
9
+ passphera_core-0.14.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
10
+ passphera_core-0.14.0.dist-info/top_level.txt,sha256=aDUX2iWGOyfzyf6XakLWTbgeWqNrypMHO074Qratyds,15
11
+ passphera_core-0.14.0.dist-info/RECORD,,
@@ -1,11 +0,0 @@
1
- passphera_core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- passphera_core/entities.py,sha256=OvVU6HzWF0GWElq_VFU-GUyittaOf5x8yMHYlAjemsE,4326
3
- passphera_core/exceptions.py,sha256=Xir2lYIH7QYHfjDQu8WJ9qIhCvP-mYcPWYN2LbbbDj8,640
4
- passphera_core/interfaces.py,sha256=8_V_08Q2_u56qVIkOOBkkFfyYKqP0aj7IpdMgoQbydI,891
5
- passphera_core/application/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- passphera_core/application/generator.py,sha256=Ki96CqrBFOvvX79Zh-FRQtiP9BMpTG_sskzyI7slbqo,2331
7
- passphera_core/application/password.py,sha256=YPnNTgBHclvsq88ZfbJMn5VHol8YizCYE-9Mv3MwTlU,3539
8
- passphera_core-0.13.0.dist-info/METADATA,sha256=IlPA2uX1eZ4pDrxGFcseGj8Z0xymkgARRKs09GBxxJI,868
9
- passphera_core-0.13.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
10
- passphera_core-0.13.0.dist-info/top_level.txt,sha256=aDUX2iWGOyfzyf6XakLWTbgeWqNrypMHO074Qratyds,15
11
- passphera_core-0.13.0.dist-info/RECORD,,