spei-python 0.48.6__tar.gz → 0.48.8__tar.gz
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.
- {spei_python-0.48.6 → spei_python-0.48.8}/PKG-INFO +1 -1
- {spei_python-0.48.6 → spei_python-0.48.8}/pyproject.toml +2 -2
- {spei_python-0.48.6 → spei_python-0.48.8}/spei/cep_generator.py +35 -26
- {spei_python-0.48.6 → spei_python-0.48.8}/spei/resources/mensaje.py +8 -4
- {spei_python-0.48.6 → spei_python-0.48.8}/spei/responses/orden.py +3 -1
- {spei_python-0.48.6 → spei_python-0.48.8}/README.md +0 -0
- {spei_python-0.48.6 → spei_python-0.48.8}/spei/README.md +0 -0
- {spei_python-0.48.6 → spei_python-0.48.8}/spei/__init__.py +0 -0
- {spei_python-0.48.6 → spei_python-0.48.8}/spei/checksum/__init__.py +0 -0
- {spei_python-0.48.6 → spei_python-0.48.8}/spei/checksum/factory.py +0 -0
- {spei_python-0.48.6 → spei_python-0.48.8}/spei/checksum/generator.py +0 -0
- {spei_python-0.48.6 → spei_python-0.48.8}/spei/checksum/types.py +0 -0
- {spei_python-0.48.6 → spei_python-0.48.8}/spei/client.py +0 -0
- {spei_python-0.48.6 → spei_python-0.48.8}/spei/errors/__init__.py +0 -0
- {spei_python-0.48.6 → spei_python-0.48.8}/spei/errors/sice.py +0 -0
- {spei_python-0.48.6 → spei_python-0.48.8}/spei/errors/spei.py +0 -0
- {spei_python-0.48.6 → spei_python-0.48.8}/spei/exceptions.py +0 -0
- {spei_python-0.48.6 → spei_python-0.48.8}/spei/mappings.py +0 -0
- {spei_python-0.48.6 → spei_python-0.48.8}/spei/requests/__init__.py +0 -0
- {spei_python-0.48.6 → spei_python-0.48.8}/spei/requests/acuse.py +0 -0
- {spei_python-0.48.6 → spei_python-0.48.8}/spei/requests/cda.py +0 -0
- {spei_python-0.48.6 → spei_python-0.48.8}/spei/requests/orden.py +0 -0
- {spei_python-0.48.6 → spei_python-0.48.8}/spei/requests/respuesta.py +0 -0
- {spei_python-0.48.6 → spei_python-0.48.8}/spei/resources/__init__.py +0 -0
- {spei_python-0.48.6 → spei_python-0.48.8}/spei/resources/acuse.py +0 -0
- {spei_python-0.48.6 → spei_python-0.48.8}/spei/resources/cda.py +0 -0
- {spei_python-0.48.6 → spei_python-0.48.8}/spei/resources/ensesion.py +0 -0
- {spei_python-0.48.6 → spei_python-0.48.8}/spei/resources/orden.py +0 -0
- {spei_python-0.48.6 → spei_python-0.48.8}/spei/resources/payments.py +0 -0
- {spei_python-0.48.6 → spei_python-0.48.8}/spei/resources/respuesta.py +0 -0
- {spei_python-0.48.6 → spei_python-0.48.8}/spei/responses/__init__.py +0 -0
- {spei_python-0.48.6 → spei_python-0.48.8}/spei/responses/acuse.py +0 -0
- {spei_python-0.48.6 → spei_python-0.48.8}/spei/responses/respuesta.py +0 -0
- {spei_python-0.48.6 → spei_python-0.48.8}/spei/sice.py +0 -0
- {spei_python-0.48.6 → spei_python-0.48.8}/spei/types/__init__.py +0 -0
- {spei_python-0.48.6 → spei_python-0.48.8}/spei/types/sice.py +0 -0
- {spei_python-0.48.6 → spei_python-0.48.8}/spei/types/spei.py +0 -0
- {spei_python-0.48.6 → spei_python-0.48.8}/spei/utils.py +0 -0
- {spei_python-0.48.6 → spei_python-0.48.8}/spei/validators.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "spei-python"
|
|
3
|
-
version = "0.48.
|
|
3
|
+
version = "0.48.8"
|
|
4
4
|
description = ""
|
|
5
5
|
authors = ["tech <tech@fondeadora.com>"]
|
|
6
6
|
readme = "README.md"
|
|
@@ -32,7 +32,7 @@ build-backend = "poetry.core.masonry.api"
|
|
|
32
32
|
|
|
33
33
|
[tool.commitizen]
|
|
34
34
|
name = "cz_conventional_commits"
|
|
35
|
-
version = "0.48.
|
|
35
|
+
version = "0.48.8"
|
|
36
36
|
tag_format = "v$version"
|
|
37
37
|
bump_message = "bump: Semantic Release Bot: Release Version: $new_version 🤖🚀 [skip ci]"
|
|
38
38
|
version_files = [
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import base64
|
|
2
|
+
import binascii
|
|
2
3
|
import datetime
|
|
3
4
|
from enum import Enum
|
|
4
|
-
from os import urandom
|
|
5
5
|
|
|
6
6
|
from cryptography.hazmat.backends import default_backend
|
|
7
7
|
from cryptography.hazmat.primitives import padding
|
|
8
8
|
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
AES_128 = algorithms.AES128
|
|
11
|
+
KEY_SIZE = int(AES_128.block_size / 8)
|
|
11
12
|
|
|
12
13
|
|
|
13
14
|
class SearchCriteria(Enum):
|
|
@@ -16,9 +17,12 @@ class SearchCriteria(Enum):
|
|
|
16
17
|
|
|
17
18
|
|
|
18
19
|
class CepGenerator(object):
|
|
19
|
-
def __init__(self,
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
def __init__(self, hex_key: str):
|
|
21
|
+
cleaned_hex_key = hex_key.replace(':', '')
|
|
22
|
+
raw_key = binascii.unhexlify(cleaned_hex_key)
|
|
23
|
+
|
|
24
|
+
self.key = raw_key[:KEY_SIZE]
|
|
25
|
+
self.iv = raw_key[KEY_SIZE:]
|
|
22
26
|
|
|
23
27
|
def generate_cep(
|
|
24
28
|
self,
|
|
@@ -45,45 +49,50 @@ class CepGenerator(object):
|
|
|
45
49
|
|
|
46
50
|
def decrypt_string(self, encrypted_data_base64: str) -> str: # noqa: WPS210
|
|
47
51
|
encrypted_data = base64.b64decode(encrypted_data_base64)
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
decrypted_data = (
|
|
52
|
-
decryptor.update(
|
|
53
|
-
encrypted_data[IV_LIMIT:],
|
|
54
|
-
)
|
|
55
|
-
+ decryptor.finalize()
|
|
56
|
-
)
|
|
52
|
+
decryptor = self.decryptor()
|
|
53
|
+
|
|
54
|
+
decrypted_data = decryptor.update(encrypted_data) + decryptor.finalize()
|
|
57
55
|
|
|
58
|
-
unpadder =
|
|
56
|
+
unpadder = self.unpadder
|
|
59
57
|
unpadded_data = unpadder.update(decrypted_data) + unpadder.finalize()
|
|
60
58
|
|
|
61
59
|
return unpadded_data.decode()
|
|
62
60
|
|
|
63
|
-
def encryptor(self,
|
|
64
|
-
return self.cipher(
|
|
61
|
+
def encryptor(self, backend=None):
|
|
62
|
+
return self.cipher(backend=backend).encryptor()
|
|
65
63
|
|
|
66
|
-
def decryptor(self,
|
|
67
|
-
return self.cipher(
|
|
64
|
+
def decryptor(self, backend=None):
|
|
65
|
+
return self.cipher(backend=backend).decryptor()
|
|
68
66
|
|
|
69
|
-
def cipher(self,
|
|
67
|
+
def cipher(self, backend=None):
|
|
70
68
|
return Cipher(
|
|
71
|
-
|
|
72
|
-
modes.CBC(iv),
|
|
69
|
+
AES_128(self.key),
|
|
70
|
+
modes.CBC(self.iv),
|
|
73
71
|
backend=backend or default_backend(),
|
|
74
72
|
)
|
|
75
73
|
|
|
74
|
+
@property
|
|
75
|
+
def padder(self):
|
|
76
|
+
return self.padding.padder()
|
|
77
|
+
|
|
78
|
+
@property
|
|
79
|
+
def unpadder(self):
|
|
80
|
+
return self.padding.unpadder()
|
|
81
|
+
|
|
82
|
+
@property
|
|
83
|
+
def padding(self):
|
|
84
|
+
return padding.PKCS7(AES_128.block_size)
|
|
85
|
+
|
|
76
86
|
def _format_date(self, date: datetime.datetime) -> str:
|
|
77
87
|
return date.strftime('%Y%m%d')
|
|
78
88
|
|
|
79
89
|
def _encrypt_string(self, string: str) -> str: # noqa: WPS210
|
|
80
|
-
|
|
81
|
-
encryptor = self.encryptor(iv)
|
|
90
|
+
encryptor = self.encryptor()
|
|
82
91
|
|
|
83
|
-
padder =
|
|
92
|
+
padder = self.padder
|
|
84
93
|
padded_data = padder.update(string.encode()) + padder.finalize()
|
|
85
94
|
|
|
86
95
|
encrypted_data = encryptor.update(padded_data) + encryptor.finalize()
|
|
87
|
-
encrypted_data_base64 = base64.b64encode(
|
|
96
|
+
encrypted_data_base64 = base64.b64encode(encrypted_data)
|
|
88
97
|
|
|
89
98
|
return encrypted_data_base64.decode()
|
|
@@ -17,9 +17,13 @@ class Mensaje(BaseModel):
|
|
|
17
17
|
|
|
18
18
|
@classmethod
|
|
19
19
|
def parse_xml(cls, mensaje): # noqa: WPS210
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
is_ensesion = mensaje.find(b'ENSESION')
|
|
21
|
+
if is_ensesion == -1:
|
|
22
|
+
decoded = mensaje.decode('utf-8')
|
|
23
|
+
else:
|
|
24
|
+
decoded = mensaje.decode('latin1').replace('&', '&amp;')
|
|
25
|
+
|
|
26
|
+
mensaje = etree.fromstring(bytes(decoded, encoding='utf-8')) # noqa: S320
|
|
23
27
|
body = mensaje.find(
|
|
24
28
|
'{http://schemas.xmlsoap.org/soap/envelope/}Body',
|
|
25
29
|
)
|
|
@@ -28,7 +32,7 @@ class Mensaje(BaseModel):
|
|
|
28
32
|
|
|
29
33
|
if ordenpago is not None:
|
|
30
34
|
element = etree.fromstring( # noqa: S320
|
|
31
|
-
bytes(ordenpago.text.strip(), encoding='
|
|
35
|
+
bytes(ordenpago.text.strip(), encoding='cp850'),
|
|
32
36
|
)
|
|
33
37
|
categoria = element.attrib['categoria']
|
|
34
38
|
|
|
@@ -31,5 +31,7 @@ class BodyElement(object):
|
|
|
31
31
|
|
|
32
32
|
class OrdenResponse(object):
|
|
33
33
|
def __new__(cls, orden):
|
|
34
|
-
mensaje = etree.fromstring(
|
|
34
|
+
mensaje = etree.fromstring( # noqa: S320
|
|
35
|
+
bytes(orden, encoding='utf-8'),
|
|
36
|
+
)
|
|
35
37
|
return OrdenPagoElement(MensajeElement(RootElement(BodyElement(mensaje))))
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|