maleo-foundation 0.3.58__py3-none-any.whl → 0.3.59__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.
@@ -2,6 +2,7 @@ import os
2
2
  from base64 import b64decode, b64encode
3
3
  from cryptography.hazmat.backends import default_backend
4
4
  from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
5
+ from maleo_foundation.enums import BaseEnums
5
6
  from maleo_foundation.expanded_types.encryption.aes import (
6
7
  MaleoFoundationAESEncryptionResultsTypes,
7
8
  )
@@ -14,7 +15,10 @@ from maleo_foundation.models.transfers.results.encryption.aes import (
14
15
  EncryptData,
15
16
  MaleoFoundationAESEncryptionResultsTransfers,
16
17
  )
17
- from maleo_foundation.utils.exceptions import BaseExceptions
18
+ from maleo_foundation.utils.exceptions.service import BaseServiceExceptions
19
+
20
+
21
+ RESOURCE = "aes_encryptions"
18
22
 
19
23
 
20
24
  class MaleoFoundationAESEncryptionClientService(ClientService):
@@ -23,8 +27,13 @@ class MaleoFoundationAESEncryptionClientService(ClientService):
23
27
  ) -> MaleoFoundationAESEncryptionResultsTypes.Encrypt:
24
28
  """Encrypt a plaintext using AES algorithm."""
25
29
 
26
- @BaseExceptions.service_exception_handler(
27
- operation="encrypting plaintext",
30
+ @BaseServiceExceptions.sync_exception_handler(
31
+ layer=BaseEnums.OperationLayer.SERVICE,
32
+ target=BaseEnums.OperationTarget.INTERNAL,
33
+ resource=RESOURCE,
34
+ operation=BaseEnums.OperationType.CREATE,
35
+ create_type=BaseEnums.CreateType.CREATE,
36
+ summary="encrypting plaintext",
28
37
  logger=self._logger,
29
38
  fail_result_class=MaleoFoundationAESEncryptionResultsTransfers.Fail,
30
39
  )
@@ -53,7 +62,15 @@ class MaleoFoundationAESEncryptionClientService(ClientService):
53
62
  ciphertext=ciphertext,
54
63
  )
55
64
  self._logger.info("Plaintext successfully encrypted")
56
- return MaleoFoundationAESEncryptionResultsTransfers.Encrypt(data=data) # type: ignore
65
+ return MaleoFoundationAESEncryptionResultsTransfers.Encrypt(
66
+ origin=BaseEnums.OperationOrigin.CLIENT,
67
+ layer=BaseEnums.OperationLayer.SERVICE,
68
+ target=BaseEnums.OperationTarget.INTERNAL,
69
+ resource=RESOURCE,
70
+ operation=BaseEnums.OperationType.CREATE,
71
+ create_type=BaseEnums.CreateType.CREATE,
72
+ data=data,
73
+ ) # type: ignore
57
74
 
58
75
  return _impl()
59
76
 
@@ -62,8 +79,13 @@ class MaleoFoundationAESEncryptionClientService(ClientService):
62
79
  ) -> MaleoFoundationAESEncryptionResultsTypes.Decrypt:
63
80
  """Decrypt a ciphertext using AES algorithm."""
64
81
 
65
- @BaseExceptions.service_exception_handler(
66
- operation="verify single encryption",
82
+ @BaseServiceExceptions.sync_exception_handler(
83
+ layer=BaseEnums.OperationLayer.SERVICE,
84
+ target=BaseEnums.OperationTarget.INTERNAL,
85
+ resource=RESOURCE,
86
+ operation=BaseEnums.OperationType.CREATE,
87
+ create_type=BaseEnums.CreateType.CREATE,
88
+ summary="verify single encryption",
67
89
  logger=self._logger,
68
90
  fail_result_class=MaleoFoundationAESEncryptionResultsTransfers.Fail,
69
91
  )
@@ -84,6 +106,14 @@ class MaleoFoundationAESEncryptionClientService(ClientService):
84
106
  ).decode()
85
107
  data = MaleoFoundationEncryptionSchemas.Plaintext(plaintext=plaintext)
86
108
  self._logger.info("Ciphertext successfully decrypted")
87
- return MaleoFoundationAESEncryptionResultsTransfers.Decrypt(data=data) # type: ignore
109
+ return MaleoFoundationAESEncryptionResultsTransfers.Decrypt(
110
+ origin=BaseEnums.OperationOrigin.CLIENT,
111
+ layer=BaseEnums.OperationLayer.SERVICE,
112
+ target=BaseEnums.OperationTarget.INTERNAL,
113
+ resource=RESOURCE,
114
+ operation=BaseEnums.OperationType.CREATE,
115
+ create_type=BaseEnums.CreateType.CREATE,
116
+ data=data,
117
+ ) # type: ignore
88
118
 
89
119
  return _impl()
@@ -13,18 +13,26 @@ from maleo_foundation.models.transfers.parameters.encryption.rsa import (
13
13
  from maleo_foundation.models.transfers.results.encryption.rsa import (
14
14
  MaleoFoundationRSAEncryptionResultsTransfers,
15
15
  )
16
- from maleo_foundation.utils.exceptions import BaseExceptions
16
+ from maleo_foundation.utils.exceptions.service import BaseServiceExceptions
17
17
  from maleo_foundation.utils.loaders.key.rsa import RSAKeyLoader
18
18
 
19
19
 
20
+ RESOURCE = "rsa_encryptions"
21
+
22
+
20
23
  class MaleoFoundationRSAEncryptionClientService(ClientService):
21
24
  def encrypt(
22
25
  self, parameters: MaleoFoundationRSAEncryptionParametersTransfers.Encrypt
23
26
  ) -> MaleoFoundationRSAEncryptionResultsTypes.Encrypt:
24
27
  """Encrypt a plaintext using RSA algorithm."""
25
28
 
26
- @BaseExceptions.service_exception_handler(
27
- operation="encrypting plaintext",
29
+ @BaseServiceExceptions.sync_exception_handler(
30
+ layer=BaseEnums.OperationLayer.SERVICE,
31
+ target=BaseEnums.OperationTarget.INTERNAL,
32
+ resource=RESOURCE,
33
+ operation=BaseEnums.OperationType.CREATE,
34
+ create_type=BaseEnums.CreateType.CREATE,
35
+ summary="encrypting plaintext",
28
36
  logger=self._logger,
29
37
  fail_result_class=MaleoFoundationRSAEncryptionResultsTransfers.Fail,
30
38
  )
@@ -60,7 +68,15 @@ class MaleoFoundationRSAEncryptionClientService(ClientService):
60
68
  ).decode("utf-8")
61
69
  data = MaleoFoundationEncryptionSchemas.Ciphertext(ciphertext=ciphertext)
62
70
  self._logger.info("Plaintext successfully encrypted")
63
- return MaleoFoundationRSAEncryptionResultsTransfers.Encrypt(data=data) # type: ignore
71
+ return MaleoFoundationRSAEncryptionResultsTransfers.Encrypt(
72
+ origin=BaseEnums.OperationOrigin.CLIENT,
73
+ layer=BaseEnums.OperationLayer.SERVICE,
74
+ target=BaseEnums.OperationTarget.INTERNAL,
75
+ resource=RESOURCE,
76
+ operation=BaseEnums.OperationType.CREATE,
77
+ create_type=BaseEnums.CreateType.CREATE,
78
+ data=data,
79
+ ) # type: ignore
64
80
 
65
81
  return _impl()
66
82
 
@@ -69,8 +85,13 @@ class MaleoFoundationRSAEncryptionClientService(ClientService):
69
85
  ) -> MaleoFoundationRSAEncryptionResultsTypes.Decrypt:
70
86
  """Decrypt a ciphertext using RSA algorithm."""
71
87
 
72
- @BaseExceptions.service_exception_handler(
73
- operation="verify single encryption",
88
+ @BaseServiceExceptions.sync_exception_handler(
89
+ layer=BaseEnums.OperationLayer.SERVICE,
90
+ target=BaseEnums.OperationTarget.INTERNAL,
91
+ resource=RESOURCE,
92
+ operation=BaseEnums.OperationType.CREATE,
93
+ create_type=BaseEnums.CreateType.CREATE,
94
+ summary="verify single encryption",
74
95
  logger=self._logger,
75
96
  fail_result_class=MaleoFoundationRSAEncryptionResultsTransfers.Fail,
76
97
  )
@@ -106,6 +127,14 @@ class MaleoFoundationRSAEncryptionClientService(ClientService):
106
127
  plaintext = cipher.decrypt(b64decode(parameters.ciphertext)).decode()
107
128
  data = MaleoFoundationEncryptionSchemas.Plaintext(plaintext=plaintext)
108
129
  self._logger.info("Ciphertext successfully decrypted")
109
- return MaleoFoundationRSAEncryptionResultsTransfers.Decrypt(data=data) # type: ignore
130
+ return MaleoFoundationRSAEncryptionResultsTransfers.Decrypt(
131
+ origin=BaseEnums.OperationOrigin.CLIENT,
132
+ layer=BaseEnums.OperationLayer.SERVICE,
133
+ target=BaseEnums.OperationTarget.INTERNAL,
134
+ resource=RESOURCE,
135
+ operation=BaseEnums.OperationType.CREATE,
136
+ create_type=BaseEnums.CreateType.CREATE,
137
+ data=data,
138
+ ) # type: ignore
110
139
 
111
140
  return _impl()
@@ -1,4 +1,5 @@
1
1
  import bcrypt
2
+ from maleo_foundation.enums import BaseEnums
2
3
  from maleo_foundation.expanded_types.hash import MaleoFoundationHashResultsTypes
3
4
  from maleo_foundation.managers.client.base import ClientService
4
5
  from maleo_foundation.models.schemas.hash import MaleoFoundationHashSchemas
@@ -8,7 +9,10 @@ from maleo_foundation.models.transfers.parameters.hash.bcrypt import (
8
9
  from maleo_foundation.models.transfers.results.hash import (
9
10
  MaleoFoundationHashResultsTransfers,
10
11
  )
11
- from maleo_foundation.utils.exceptions import BaseExceptions
12
+ from maleo_foundation.utils.exceptions.service import BaseServiceExceptions
13
+
14
+
15
+ RESOURCE = "bcrypt_hashes"
12
16
 
13
17
 
14
18
  class MaleoFoundationBcryptHashClientService(ClientService):
@@ -17,8 +21,13 @@ class MaleoFoundationBcryptHashClientService(ClientService):
17
21
  ) -> MaleoFoundationHashResultsTypes.Hash:
18
22
  """Generate a bcrypt hash for the given message."""
19
23
 
20
- @BaseExceptions.service_exception_handler(
21
- operation="hashing single message",
24
+ @BaseServiceExceptions.sync_exception_handler(
25
+ layer=BaseEnums.OperationLayer.SERVICE,
26
+ target=BaseEnums.OperationTarget.INTERNAL,
27
+ resource=RESOURCE,
28
+ operation=BaseEnums.OperationType.CREATE,
29
+ create_type=BaseEnums.CreateType.CREATE,
30
+ summary="hashing single message",
22
31
  logger=self._logger,
23
32
  fail_result_class=MaleoFoundationHashResultsTransfers.Fail,
24
33
  )
@@ -28,7 +37,15 @@ class MaleoFoundationBcryptHashClientService(ClientService):
28
37
  ).decode()
29
38
  data = MaleoFoundationHashSchemas.Hash(hash=hash)
30
39
  self._logger.info("Message successfully hashed")
31
- return MaleoFoundationHashResultsTransfers.Hash(data=data)
40
+ return MaleoFoundationHashResultsTransfers.Hash(
41
+ origin=BaseEnums.OperationOrigin.CLIENT,
42
+ layer=BaseEnums.OperationLayer.SERVICE,
43
+ target=BaseEnums.OperationTarget.INTERNAL,
44
+ resource=RESOURCE,
45
+ operation=BaseEnums.OperationType.CREATE,
46
+ create_type=BaseEnums.CreateType.CREATE,
47
+ data=data,
48
+ ) # type: ignore
32
49
 
33
50
  return _impl()
34
51
 
@@ -37,8 +54,13 @@ class MaleoFoundationBcryptHashClientService(ClientService):
37
54
  ) -> MaleoFoundationHashResultsTypes.Verify:
38
55
  """Verify a message against the given message hash."""
39
56
 
40
- @BaseExceptions.service_exception_handler(
41
- operation="verify single hash",
57
+ @BaseServiceExceptions.sync_exception_handler(
58
+ layer=BaseEnums.OperationLayer.SERVICE,
59
+ target=BaseEnums.OperationTarget.INTERNAL,
60
+ resource=RESOURCE,
61
+ operation=BaseEnums.OperationType.CREATE,
62
+ create_type=BaseEnums.CreateType.CREATE,
63
+ summary="verify single hash",
42
64
  logger=self._logger,
43
65
  fail_result_class=MaleoFoundationHashResultsTransfers.Fail,
44
66
  )
@@ -49,6 +71,14 @@ class MaleoFoundationBcryptHashClientService(ClientService):
49
71
  )
50
72
  data = MaleoFoundationHashSchemas.IsValid(is_valid=is_valid)
51
73
  self._logger.info("Hash successfully verified")
52
- return MaleoFoundationHashResultsTransfers.Verify(data=data)
74
+ return MaleoFoundationHashResultsTransfers.Verify(
75
+ origin=BaseEnums.OperationOrigin.CLIENT,
76
+ layer=BaseEnums.OperationLayer.SERVICE,
77
+ target=BaseEnums.OperationTarget.INTERNAL,
78
+ resource=RESOURCE,
79
+ operation=BaseEnums.OperationType.CREATE,
80
+ create_type=BaseEnums.CreateType.CREATE,
81
+ data=data,
82
+ ) # type: ignore
53
83
 
54
84
  return _impl()
@@ -1,4 +1,5 @@
1
1
  from Crypto.Hash import HMAC, SHA256
2
+ from maleo_foundation.enums import BaseEnums
2
3
  from maleo_foundation.expanded_types.hash import MaleoFoundationHashResultsTypes
3
4
  from maleo_foundation.managers.client.base import ClientService
4
5
  from maleo_foundation.models.schemas.hash import MaleoFoundationHashSchemas
@@ -8,7 +9,10 @@ from maleo_foundation.models.transfers.parameters.hash.hmac import (
8
9
  from maleo_foundation.models.transfers.results.hash import (
9
10
  MaleoFoundationHashResultsTransfers,
10
11
  )
11
- from maleo_foundation.utils.exceptions import BaseExceptions
12
+ from maleo_foundation.utils.exceptions.service import BaseServiceExceptions
13
+
14
+
15
+ RESOURCE = "hmac_hashes"
12
16
 
13
17
 
14
18
  class MaleoFoundationHMACHashClientService(ClientService):
@@ -17,8 +21,13 @@ class MaleoFoundationHMACHashClientService(ClientService):
17
21
  ) -> MaleoFoundationHashResultsTypes.Hash:
18
22
  """Generate a hmac hash for the given message."""
19
23
 
20
- @BaseExceptions.service_exception_handler(
21
- operation="hashing single message",
24
+ @BaseServiceExceptions.sync_exception_handler(
25
+ layer=BaseEnums.OperationLayer.SERVICE,
26
+ target=BaseEnums.OperationTarget.INTERNAL,
27
+ resource=RESOURCE,
28
+ operation=BaseEnums.OperationType.CREATE,
29
+ create_type=BaseEnums.CreateType.CREATE,
30
+ summary="hashing single message",
22
31
  logger=self._logger,
23
32
  fail_result_class=MaleoFoundationHashResultsTransfers.Fail,
24
33
  )
@@ -30,7 +39,15 @@ class MaleoFoundationHMACHashClientService(ClientService):
30
39
  ).hexdigest()
31
40
  data = MaleoFoundationHashSchemas.Hash(hash=hash)
32
41
  self._logger.info("Message successfully hashed")
33
- return MaleoFoundationHashResultsTransfers.Hash(data=data)
42
+ return MaleoFoundationHashResultsTransfers.Hash(
43
+ origin=BaseEnums.OperationOrigin.CLIENT,
44
+ layer=BaseEnums.OperationLayer.SERVICE,
45
+ target=BaseEnums.OperationTarget.INTERNAL,
46
+ resource=RESOURCE,
47
+ operation=BaseEnums.OperationType.CREATE,
48
+ create_type=BaseEnums.CreateType.CREATE,
49
+ data=data,
50
+ ) # type: ignore
34
51
 
35
52
  return _impl()
36
53
 
@@ -39,8 +56,13 @@ class MaleoFoundationHMACHashClientService(ClientService):
39
56
  ) -> MaleoFoundationHashResultsTypes.Verify:
40
57
  """Verify a message against the given message hash."""
41
58
 
42
- @BaseExceptions.service_exception_handler(
43
- operation="verify single hash",
59
+ @BaseServiceExceptions.sync_exception_handler(
60
+ layer=BaseEnums.OperationLayer.SERVICE,
61
+ target=BaseEnums.OperationTarget.INTERNAL,
62
+ resource=RESOURCE,
63
+ operation=BaseEnums.OperationType.CREATE,
64
+ create_type=BaseEnums.CreateType.CREATE,
65
+ summary="verify single hash",
44
66
  logger=self._logger,
45
67
  fail_result_class=MaleoFoundationHashResultsTransfers.Fail,
46
68
  )
@@ -53,6 +75,14 @@ class MaleoFoundationHMACHashClientService(ClientService):
53
75
  is_valid = computed_hash == parameters.hash
54
76
  data = MaleoFoundationHashSchemas.IsValid(is_valid=is_valid)
55
77
  self._logger.info("Hash successfully verified")
56
- return MaleoFoundationHashResultsTransfers.Verify(data=data)
78
+ return MaleoFoundationHashResultsTransfers.Verify(
79
+ origin=BaseEnums.OperationOrigin.CLIENT,
80
+ layer=BaseEnums.OperationLayer.SERVICE,
81
+ target=BaseEnums.OperationTarget.INTERNAL,
82
+ resource=RESOURCE,
83
+ operation=BaseEnums.OperationType.CREATE,
84
+ create_type=BaseEnums.CreateType.CREATE,
85
+ data=data,
86
+ ) # type: ignore
57
87
 
58
88
  return _impl()
@@ -1,4 +1,5 @@
1
1
  from Crypto.Hash import SHA256
2
+ from maleo_foundation.enums import BaseEnums
2
3
  from maleo_foundation.expanded_types.hash import MaleoFoundationHashResultsTypes
3
4
  from maleo_foundation.managers.client.base import ClientService
4
5
  from maleo_foundation.models.schemas.hash import MaleoFoundationHashSchemas
@@ -8,7 +9,10 @@ from maleo_foundation.models.transfers.parameters.hash.sha256 import (
8
9
  from maleo_foundation.models.transfers.results.hash import (
9
10
  MaleoFoundationHashResultsTransfers,
10
11
  )
11
- from maleo_foundation.utils.exceptions import BaseExceptions
12
+ from maleo_foundation.utils.exceptions.service import BaseServiceExceptions
13
+
14
+
15
+ RESOURCE = "sha256_hashes"
12
16
 
13
17
 
14
18
  class MaleoFoundationSHA256HashClientService(ClientService):
@@ -17,8 +21,13 @@ class MaleoFoundationSHA256HashClientService(ClientService):
17
21
  ) -> MaleoFoundationHashResultsTypes.Hash:
18
22
  """Generate a sha256 hash for the given message."""
19
23
 
20
- @BaseExceptions.service_exception_handler(
21
- operation="hashing single message",
24
+ @BaseServiceExceptions.sync_exception_handler(
25
+ layer=BaseEnums.OperationLayer.SERVICE,
26
+ target=BaseEnums.OperationTarget.INTERNAL,
27
+ resource=RESOURCE,
28
+ operation=BaseEnums.OperationType.CREATE,
29
+ create_type=BaseEnums.CreateType.CREATE,
30
+ summary="hashing single message",
22
31
  logger=self._logger,
23
32
  fail_result_class=MaleoFoundationHashResultsTransfers.Fail,
24
33
  )
@@ -26,7 +35,15 @@ class MaleoFoundationSHA256HashClientService(ClientService):
26
35
  hash = SHA256.new(parameters.message.encode()).hexdigest()
27
36
  data = MaleoFoundationHashSchemas.Hash(hash=hash)
28
37
  self._logger.info("Message successfully hashed")
29
- return MaleoFoundationHashResultsTransfers.Hash(data=data)
38
+ return MaleoFoundationHashResultsTransfers.Hash(
39
+ origin=BaseEnums.OperationOrigin.CLIENT,
40
+ layer=BaseEnums.OperationLayer.SERVICE,
41
+ target=BaseEnums.OperationTarget.INTERNAL,
42
+ resource=RESOURCE,
43
+ operation=BaseEnums.OperationType.CREATE,
44
+ create_type=BaseEnums.CreateType.CREATE,
45
+ data=data,
46
+ ) # type: ignore
30
47
 
31
48
  return _impl()
32
49
 
@@ -35,8 +52,13 @@ class MaleoFoundationSHA256HashClientService(ClientService):
35
52
  ) -> MaleoFoundationHashResultsTypes.Verify:
36
53
  """Verify a message against the given message hash."""
37
54
 
38
- @BaseExceptions.service_exception_handler(
39
- operation="verify single hash",
55
+ @BaseServiceExceptions.sync_exception_handler(
56
+ layer=BaseEnums.OperationLayer.SERVICE,
57
+ target=BaseEnums.OperationTarget.INTERNAL,
58
+ resource=RESOURCE,
59
+ operation=BaseEnums.OperationType.CREATE,
60
+ create_type=BaseEnums.CreateType.CREATE,
61
+ summary="verify single hash",
40
62
  logger=self._logger,
41
63
  fail_result_class=MaleoFoundationHashResultsTransfers.Fail,
42
64
  )
@@ -45,6 +67,14 @@ class MaleoFoundationSHA256HashClientService(ClientService):
45
67
  is_valid = computed_hash == parameters.hash
46
68
  data = MaleoFoundationHashSchemas.IsValid(is_valid=is_valid)
47
69
  self._logger.info("Hash successfully verified")
48
- return MaleoFoundationHashResultsTransfers.Verify(data=data)
70
+ return MaleoFoundationHashResultsTransfers.Verify(
71
+ origin=BaseEnums.OperationOrigin.CLIENT,
72
+ layer=BaseEnums.OperationLayer.SERVICE,
73
+ target=BaseEnums.OperationTarget.INTERNAL,
74
+ resource=RESOURCE,
75
+ operation=BaseEnums.OperationType.CREATE,
76
+ create_type=BaseEnums.CreateType.CREATE,
77
+ data=data,
78
+ ) # type: ignore
49
79
 
50
80
  return _impl()
@@ -1,6 +1,7 @@
1
1
  from cryptography.hazmat.backends import default_backend
2
2
  from cryptography.hazmat.primitives.asymmetric import rsa
3
3
  from cryptography.hazmat.primitives import serialization
4
+ from maleo_foundation.enums import BaseEnums
4
5
  from maleo_foundation.expanded_types.key import MaleoFoundationKeyResultsTypes
5
6
  from maleo_foundation.managers.client.base import ClientService
6
7
  from maleo_foundation.models.transfers.general.key import (
@@ -12,7 +13,10 @@ from maleo_foundation.models.transfers.parameters.key import (
12
13
  from maleo_foundation.models.transfers.results.key import (
13
14
  MaleoFoundationKeyResultsTransfers,
14
15
  )
15
- from maleo_foundation.utils.exceptions import BaseExceptions
16
+ from maleo_foundation.utils.exceptions.service import BaseServiceExceptions
17
+
18
+
19
+ RESOURCE = "keys"
16
20
 
17
21
 
18
22
  class MaleoFoundationKeyClientService(ClientService):
@@ -21,8 +25,13 @@ class MaleoFoundationKeyClientService(ClientService):
21
25
  ) -> MaleoFoundationKeyResultsTypes.CreatePrivate:
22
26
  """Create an RSA private key with X.509 encoding in .pem format."""
23
27
 
24
- @BaseExceptions.service_exception_handler(
25
- operation="creating private key",
28
+ @BaseServiceExceptions.sync_exception_handler(
29
+ layer=BaseEnums.OperationLayer.SERVICE,
30
+ target=BaseEnums.OperationTarget.INTERNAL,
31
+ resource=RESOURCE,
32
+ operation=BaseEnums.OperationType.CREATE,
33
+ create_type=BaseEnums.CreateType.CREATE,
34
+ summary="creating private key",
26
35
  logger=self._logger,
27
36
  fail_result_class=MaleoFoundationKeyResultsTransfers.Fail,
28
37
  )
@@ -52,7 +61,15 @@ class MaleoFoundationKeyClientService(ClientService):
52
61
  data = MaleoFoundationKeyGeneralTransfers.PrivateKey(
53
62
  value=private_key_bytes.decode()
54
63
  ) # type: ignore
55
- return MaleoFoundationKeyResultsTransfers.CreatePrivate(data=data) # type: ignore
64
+ return MaleoFoundationKeyResultsTransfers.CreatePrivate(
65
+ origin=BaseEnums.OperationOrigin.CLIENT,
66
+ layer=BaseEnums.OperationLayer.SERVICE,
67
+ target=BaseEnums.OperationTarget.INTERNAL,
68
+ resource=RESOURCE,
69
+ operation=BaseEnums.OperationType.CREATE,
70
+ create_type=BaseEnums.CreateType.CREATE,
71
+ data=data,
72
+ ) # type: ignore
56
73
 
57
74
  return _impl()
58
75
 
@@ -61,8 +78,13 @@ class MaleoFoundationKeyClientService(ClientService):
61
78
  ) -> MaleoFoundationKeyResultsTypes.CreatePublic:
62
79
  """Create an RSA public key with X.509 encoding in .pem format."""
63
80
 
64
- @BaseExceptions.service_exception_handler(
65
- operation="creating public key",
81
+ @BaseServiceExceptions.sync_exception_handler(
82
+ layer=BaseEnums.OperationLayer.SERVICE,
83
+ target=BaseEnums.OperationTarget.INTERNAL,
84
+ resource=RESOURCE,
85
+ operation=BaseEnums.OperationType.CREATE,
86
+ create_type=BaseEnums.CreateType.CREATE,
87
+ summary="creating public key",
66
88
  logger=self._logger,
67
89
  fail_result_class=MaleoFoundationKeyResultsTransfers.Fail,
68
90
  )
@@ -87,7 +109,15 @@ class MaleoFoundationKeyClientService(ClientService):
87
109
  data = MaleoFoundationKeyGeneralTransfers.PublicKey(
88
110
  value=public_key_bytes.decode()
89
111
  ) # type: ignore
90
- return MaleoFoundationKeyResultsTransfers.CreatePublic(data=data) # type: ignore
112
+ return MaleoFoundationKeyResultsTransfers.CreatePublic(
113
+ origin=BaseEnums.OperationOrigin.CLIENT,
114
+ layer=BaseEnums.OperationLayer.SERVICE,
115
+ target=BaseEnums.OperationTarget.INTERNAL,
116
+ resource=RESOURCE,
117
+ operation=BaseEnums.OperationType.CREATE,
118
+ create_type=BaseEnums.CreateType.CREATE,
119
+ data=data,
120
+ ) # type: ignore
91
121
 
92
122
  return _impl()
93
123
 
@@ -96,8 +126,13 @@ class MaleoFoundationKeyClientService(ClientService):
96
126
  ) -> MaleoFoundationKeyResultsTypes.CreatePair:
97
127
  """Create an RSA key pair with X.509 encoding in .pem format."""
98
128
 
99
- @BaseExceptions.service_exception_handler(
100
- operation="creating key pair",
129
+ @BaseServiceExceptions.sync_exception_handler(
130
+ layer=BaseEnums.OperationLayer.SERVICE,
131
+ target=BaseEnums.OperationTarget.INTERNAL,
132
+ resource=RESOURCE,
133
+ operation=BaseEnums.OperationType.CREATE,
134
+ create_type=BaseEnums.CreateType.CREATE,
135
+ summary="creating key pair",
101
136
  logger=self._logger,
102
137
  fail_result_class=MaleoFoundationKeyResultsTransfers.Fail,
103
138
  )
@@ -141,6 +176,14 @@ class MaleoFoundationKeyClientService(ClientService):
141
176
  data = MaleoFoundationKeyGeneralTransfers.KeyPair(
142
177
  private=private, public=public
143
178
  )
144
- return MaleoFoundationKeyResultsTransfers.CreatePair(data=data) # type: ignore
179
+ return MaleoFoundationKeyResultsTransfers.CreatePair(
180
+ origin=BaseEnums.OperationOrigin.CLIENT,
181
+ layer=BaseEnums.OperationLayer.SERVICE,
182
+ target=BaseEnums.OperationTarget.INTERNAL,
183
+ resource=RESOURCE,
184
+ operation=BaseEnums.OperationType.CREATE,
185
+ create_type=BaseEnums.CreateType.CREATE,
186
+ data=data,
187
+ ) # type: ignore
145
188
 
146
189
  return _impl()
@@ -13,16 +13,24 @@ from maleo_foundation.models.transfers.parameters.signature import (
13
13
  from maleo_foundation.models.transfers.results.signature import (
14
14
  MaleoFoundationSignatureResultsTransfers,
15
15
  )
16
- from maleo_foundation.utils.exceptions import BaseExceptions
16
+ from maleo_foundation.utils.exceptions.service import BaseServiceExceptions
17
17
  from maleo_foundation.utils.loaders.key.rsa import RSAKeyLoader
18
18
 
19
19
 
20
+ RESOURCE = "signatures"
21
+
22
+
20
23
  class MaleoFoundationSignatureClientService(ClientService):
21
24
  def sign(
22
25
  self, parameters: MaleoFoundationSignatureParametersTransfers.Sign
23
26
  ) -> MaleoFoundationSignatureResultsTypes.Sign:
24
- @BaseExceptions.service_exception_handler(
25
- operation="signing single message",
27
+ @BaseServiceExceptions.sync_exception_handler(
28
+ layer=BaseEnums.OperationLayer.SERVICE,
29
+ target=BaseEnums.OperationTarget.INTERNAL,
30
+ resource=RESOURCE,
31
+ operation=BaseEnums.OperationType.CREATE,
32
+ create_type=BaseEnums.CreateType.CREATE,
33
+ summary="signing single message",
26
34
  logger=self._logger,
27
35
  fail_result_class=MaleoFoundationSignatureResultsTransfers.Fail,
28
36
  )
@@ -58,15 +66,28 @@ class MaleoFoundationSignatureClientService(ClientService):
58
66
  ).decode() # * Sign the hashed message
59
67
  data = MaleoFoundationSignatureSchemas.Signature(signature=signature)
60
68
  self._logger.info("Message successfully signed")
61
- return MaleoFoundationSignatureResultsTransfers.Sign(data=data) # type: ignore
69
+ return MaleoFoundationSignatureResultsTransfers.Sign(
70
+ origin=BaseEnums.OperationOrigin.CLIENT,
71
+ layer=BaseEnums.OperationLayer.SERVICE,
72
+ target=BaseEnums.OperationTarget.INTERNAL,
73
+ resource=RESOURCE,
74
+ operation=BaseEnums.OperationType.CREATE,
75
+ create_type=BaseEnums.CreateType.CREATE,
76
+ data=data,
77
+ ) # type: ignore
62
78
 
63
79
  return _impl()
64
80
 
65
81
  def verify(
66
82
  self, parameters: MaleoFoundationSignatureParametersTransfers.Verify
67
83
  ) -> MaleoFoundationSignatureResultsTypes.Verify:
68
- @BaseExceptions.service_exception_handler(
69
- operation="verify single signature",
84
+ @BaseServiceExceptions.sync_exception_handler(
85
+ layer=BaseEnums.OperationLayer.SERVICE,
86
+ target=BaseEnums.OperationTarget.INTERNAL,
87
+ resource=RESOURCE,
88
+ operation=BaseEnums.OperationType.CREATE,
89
+ create_type=BaseEnums.CreateType.CREATE,
90
+ summary="verify single signature",
70
91
  logger=self._logger,
71
92
  fail_result_class=MaleoFoundationSignatureResultsTransfers.Fail,
72
93
  )
@@ -103,6 +124,14 @@ class MaleoFoundationSignatureClientService(ClientService):
103
124
  is_valid = False
104
125
  data = MaleoFoundationSignatureSchemas.IsValid(is_valid=is_valid)
105
126
  self._logger.info("Signature successfully verified")
106
- return MaleoFoundationSignatureResultsTransfers.Verify(data=data) # type: ignore
127
+ return MaleoFoundationSignatureResultsTransfers.Verify(
128
+ origin=BaseEnums.OperationOrigin.CLIENT,
129
+ layer=BaseEnums.OperationLayer.SERVICE,
130
+ target=BaseEnums.OperationTarget.INTERNAL,
131
+ resource=RESOURCE,
132
+ operation=BaseEnums.OperationType.CREATE,
133
+ create_type=BaseEnums.CreateType.CREATE,
134
+ data=data,
135
+ ) # type: ignore
107
136
 
108
137
  return _impl()
@@ -12,16 +12,24 @@ from maleo_foundation.models.transfers.parameters.token import (
12
12
  from maleo_foundation.models.transfers.results.token import (
13
13
  MaleoFoundationTokenResultsTransfers,
14
14
  )
15
- from maleo_foundation.utils.exceptions import BaseExceptions
15
+ from maleo_foundation.utils.exceptions.service import BaseServiceExceptions
16
16
  from maleo_foundation.utils.loaders.key.rsa import RSAKeyLoader
17
17
 
18
18
 
19
+ RESOURCE = "tokens"
20
+
21
+
19
22
  class MaleoFoundationTokenClientService(ClientService):
20
23
  def encode(
21
24
  self, parameters: MaleoFoundationTokenParametersTransfers.Encode
22
25
  ) -> MaleoFoundationTokenResultsTypes.Encode:
23
- @BaseExceptions.service_exception_handler(
24
- operation="encoding a payload into a token",
26
+ @BaseServiceExceptions.sync_exception_handler(
27
+ layer=BaseEnums.OperationLayer.SERVICE,
28
+ target=BaseEnums.OperationTarget.INTERNAL,
29
+ resource=RESOURCE,
30
+ operation=BaseEnums.OperationType.CREATE,
31
+ create_type=BaseEnums.CreateType.CREATE,
32
+ summary="encoding a payload into a token",
25
33
  logger=self._logger,
26
34
  fail_result_class=MaleoFoundationTokenResultsTransfers.Fail,
27
35
  )
@@ -58,15 +66,28 @@ class MaleoFoundationTokenClientService(ClientService):
58
66
  payload=payload, key=private_key.export_key(), algorithm="RS256"
59
67
  )
60
68
  data = MaleoFoundationTokenSchemas.Token(token=token)
61
- return MaleoFoundationTokenResultsTransfers.Encode(data=data) # type: ignore
69
+ return MaleoFoundationTokenResultsTransfers.Encode(
70
+ origin=BaseEnums.OperationOrigin.CLIENT,
71
+ layer=BaseEnums.OperationLayer.SERVICE,
72
+ target=BaseEnums.OperationTarget.INTERNAL,
73
+ resource=RESOURCE,
74
+ operation=BaseEnums.OperationType.CREATE,
75
+ create_type=BaseEnums.CreateType.CREATE,
76
+ data=data,
77
+ ) # type: ignore
62
78
 
63
79
  return _impl()
64
80
 
65
81
  def decode(
66
82
  self, parameters: MaleoFoundationTokenParametersTransfers.Decode
67
83
  ) -> MaleoFoundationTokenResultsTypes.Decode:
68
- @BaseExceptions.service_exception_handler(
69
- operation="decoding a token into a payload",
84
+ @BaseServiceExceptions.sync_exception_handler(
85
+ layer=BaseEnums.OperationLayer.SERVICE,
86
+ target=BaseEnums.OperationTarget.INTERNAL,
87
+ resource=RESOURCE,
88
+ operation=BaseEnums.OperationType.CREATE,
89
+ create_type=BaseEnums.CreateType.CREATE,
90
+ summary="decoding a token into a payload",
70
91
  logger=self._logger,
71
92
  fail_result_class=MaleoFoundationTokenResultsTransfers.Fail,
72
93
  )
@@ -100,6 +121,14 @@ class MaleoFoundationTokenClientService(ClientService):
100
121
  data = MaleoFoundationTokenGeneralTransfers.DecodePayload.model_validate(
101
122
  payload
102
123
  )
103
- return MaleoFoundationTokenResultsTransfers.Decode(data=data) # type: ignore
124
+ return MaleoFoundationTokenResultsTransfers.Decode(
125
+ origin=BaseEnums.OperationOrigin.CLIENT,
126
+ layer=BaseEnums.OperationLayer.SERVICE,
127
+ target=BaseEnums.OperationTarget.INTERNAL,
128
+ resource=RESOURCE,
129
+ operation=BaseEnums.OperationType.CREATE,
130
+ create_type=BaseEnums.CreateType.CREATE,
131
+ data=data,
132
+ ) # type: ignore
104
133
 
105
134
  return _impl()
maleo_foundation/enums.py CHANGED
@@ -110,6 +110,7 @@ class BaseEnums:
110
110
  CACHE = "cache"
111
111
  CONTROLLER = "controller"
112
112
  DATABASE = "database"
113
+ INTERNAL = "internal"
113
114
  MICROSERVICE = "microservice"
114
115
  THIRD_PARTY = "third_party"
115
116
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: maleo_foundation
3
- Version: 0.3.58
3
+ Version: 0.3.59
4
4
  Summary: Foundation package for Maleo
5
5
  Author-email: Agra Bima Yuda <agra@nexmedis.com>
6
6
  License: MIT
@@ -2,23 +2,23 @@ maleo_foundation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,
2
2
  maleo_foundation/authentication.py,sha256=2Y2py-teDSO_YTFdZiPtuYhC8r3qIzn7CKyLNN8b2NQ,2727
3
3
  maleo_foundation/authorization.py,sha256=8P1hleBYRv8kda4uQcbHVujHVAlI92YV1Flfzf-oJEU,285
4
4
  maleo_foundation/constants.py,sha256=cgW2TjXYEdQRoYCL3fMk3r5B2Yr-Av67CaEAdY5SZ6o,1529
5
- maleo_foundation/enums.py,sha256=AwfCsYBa8ieqxc6N0gVwqJ7GFj7M76qI1mDw_9LrU9I,6153
5
+ maleo_foundation/enums.py,sha256=mmyhys-vcx9CQhTx3QVf_NiQYIwWBSN8VTXmnB3w5GU,6183
6
6
  maleo_foundation/extended_types.py,sha256=oOAYc5f89WcPt5OWEaNdeceENHiPVr4KDhdttg6bA_w,305
7
7
  maleo_foundation/rest_controller_result.py,sha256=uZxBxZ5hB98q1B4hNyRigHcO0560NYfUjq8L662aOPw,2172
8
8
  maleo_foundation/types.py,sha256=Tq50KOISbnsMslVGBCqlY77lRAQZa-UUFDGqqwRglow,2466
9
9
  maleo_foundation/client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
10
  maleo_foundation/client/manager.py,sha256=5Ww2CNbKOT4nifI8roO77xlBrxIKCTCUEJHCNbRjGX4,2729
11
11
  maleo_foundation/client/services/__init__.py,sha256=srDKoa3zRt-PvfHcXlFJbwagT0O3wwicL3qbMb3Odug,1104
12
- maleo_foundation/client/services/key.py,sha256=YYKgVARQiznJ6Cs1xXRYBA-jSrcBP-w1lKKo0xOqrq4,5976
13
- maleo_foundation/client/services/signature.py,sha256=_xXtSk2y0fX4ilhGoVH8Q3nS2dxVBep2EIZXrJgBZoc,5121
14
- maleo_foundation/client/services/token.py,sha256=mYxaZKxei2plhkpoKm5QWNRO0instWuoXkrnnoD4lRo,4825
12
+ maleo_foundation/client/services/key.py,sha256=2OzlBygNsAW9WkTxHkQNneAy5jvrzXuxHvN-E5mBkxY,7856
13
+ maleo_foundation/client/services/signature.py,sha256=c9uWHDjUsONlA9vwU_EBetsmUNc97qsHf4OfBzyi0MQ,6362
14
+ maleo_foundation/client/services/token.py,sha256=zAJ1Gg8diodt1eKfv-t9DRgp2JttU4wq65p-Zyhyfeo,6062
15
15
  maleo_foundation/client/services/encryption/__init__.py,sha256=-rnOE-p0B9vEpBHBuMG3jzfZAwH6_GYNx6_ctQOBHCQ,644
16
- maleo_foundation/client/services/encryption/aes.py,sha256=nIMognacAIqFStwa_HcLvmtb-8YaaXmJkeNMwB0BFIc,3898
17
- maleo_foundation/client/services/encryption/rsa.py,sha256=JRWh5bfQG3Ry2ViEIXdbaXa_JopWtAOJg_HpanzOZdQ,5383
16
+ maleo_foundation/client/services/encryption/aes.py,sha256=UuM4mKFCgcNgV5bZj64DRyNx27pii21uCHTVKvQMKQY,5189
17
+ maleo_foundation/client/services/encryption/rsa.py,sha256=sL3uxqIZuerWGkvqRWLhdBq6Zkrk0C9AMnsv6-8A6gY,6629
18
18
  maleo_foundation/client/services/hash/__init__.py,sha256=W4O-Novao01fqy_rTDOC6TQS7-l-wSQUyGCkn49JqvY,830
19
- maleo_foundation/client/services/hash/bcrypt.py,sha256=x5qcWhkwexOURVyepHHbHr2Ttd5Q86yHRyDyKmkZr4E,2204
20
- maleo_foundation/client/services/hash/hmac.py,sha256=zw0hVXLnxNLR_bAJhX8Lu6JIADw1zp3pzd_-dhHBsKU,2348
21
- maleo_foundation/client/services/hash/sha256.py,sha256=MhgyTX--VyQote7eLxQnn80tguCR2u4O2LGdSs3cyQ4,2130
19
+ maleo_foundation/client/services/hash/bcrypt.py,sha256=x2tzOIjOs9WuF76P-rOT8Drtbt1ykPgHGqRuRC5VzIY,3525
20
+ maleo_foundation/client/services/hash/hmac.py,sha256=NN8acXUMvZvxoMcYnt0OcIeq4WWW7Va5fLmswSSTRbg,3667
21
+ maleo_foundation/client/services/hash/sha256.py,sha256=Ei9yg6ta60gTaycF33jGKHUrctGEKFeRVvzoKsD0LgY,3451
22
22
  maleo_foundation/expanded_types/__init__.py,sha256=5GYECG5mEaH7p3kTH0CH8LUDnIW5URm9do-FYe0QtnU,297
23
23
  maleo_foundation/expanded_types/client.py,sha256=mcFGAECXp4jIzG1P_831MRBa4F3RYnZ2JaIHZHXw-jU,2375
24
24
  maleo_foundation/expanded_types/general.py,sha256=Yo86OCtqzvaMcQuNL4uE3SSRlAiABXZ4Vurf85SCBi4,1476
@@ -135,7 +135,7 @@ maleo_foundation/utils/loaders/credential/__init__.py,sha256=g-cAxkTE2EtHaG8Tv52
135
135
  maleo_foundation/utils/loaders/credential/google.py,sha256=GCJl-bsKSSxoE_ERAkIzRrRNIbIEeqYOhHwzFuBr0mk,6576
136
136
  maleo_foundation/utils/loaders/key/__init__.py,sha256=RfqIbUxkdlx1xrbzJZPD_JHiRFNFLRuQs8JoUPCGCv4,108
137
137
  maleo_foundation/utils/loaders/key/rsa.py,sha256=UXcP0rr4QVacTsHLNQuU05wcow5CHWz-JW-zsVxlbPs,4121
138
- maleo_foundation-0.3.58.dist-info/METADATA,sha256=x1DAgEqufMl2OJFRrcaJW1yFqxVfbRQBJOPwmivEONA,4150
139
- maleo_foundation-0.3.58.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
140
- maleo_foundation-0.3.58.dist-info/top_level.txt,sha256=_iBos3F_bhEOdjOnzeiEYSrCucasc810xXtLBXI8cQc,17
141
- maleo_foundation-0.3.58.dist-info/RECORD,,
138
+ maleo_foundation-0.3.59.dist-info/METADATA,sha256=p20luMK_I1f5VTK6U0i3ai5XEScDdClNyEw8MyoJTWU,4150
139
+ maleo_foundation-0.3.59.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
140
+ maleo_foundation-0.3.59.dist-info/top_level.txt,sha256=_iBos3F_bhEOdjOnzeiEYSrCucasc810xXtLBXI8cQc,17
141
+ maleo_foundation-0.3.59.dist-info/RECORD,,