dana-python 2.2.2__py3-none-any.whl → 3.0.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.
- dana/utils/snap_configuration.py +3 -3
- dana/webhook/webhook.py +38 -16
- {dana_python-2.2.2.dist-info → dana_python-3.0.0.dist-info}/METADATA +7 -10
- {dana_python-2.2.2.dist-info → dana_python-3.0.0.dist-info}/RECORD +7 -7
- {dana_python-2.2.2.dist-info → dana_python-3.0.0.dist-info}/WHEEL +1 -1
- {dana_python-2.2.2.dist-info → dana_python-3.0.0.dist-info}/licenses/LICENSE +0 -0
- {dana_python-2.2.2.dist-info → dana_python-3.0.0.dist-info}/top_level.txt +0 -0
dana/utils/snap_configuration.py
CHANGED
|
@@ -231,9 +231,9 @@ class SnapConfiguration(BaseConfiguration):
|
|
|
231
231
|
) -> None:
|
|
232
232
|
"""Constructor
|
|
233
233
|
"""
|
|
234
|
-
self.host = "
|
|
234
|
+
self.host = "https://api.sandbox.dana.id" if (api_key["DANA_ENV"] == Env.SANDBOX or api_key["ENV"] == Env.SANDBOX) else \
|
|
235
235
|
"https://api.saas.dana.id" if (api_key["DANA_ENV"] == Env.PRODUCTION or api_key["ENV"] == Env.PRODUCTION) else None
|
|
236
|
-
self._base_path = "
|
|
236
|
+
self._base_path = "https://api.sandbox.dana.id" if (api_key["DANA_ENV"] == Env.SANDBOX or api_key["ENV"] == Env.SANDBOX) else \
|
|
237
237
|
"https://api.saas.dana.id" if (api_key["DANA_ENV"] == Env.PRODUCTION or api_key["ENV"] == Env.PRODUCTION) else None
|
|
238
238
|
"""Default Base url
|
|
239
239
|
"""
|
|
@@ -595,7 +595,7 @@ class SnapConfiguration(BaseConfiguration):
|
|
|
595
595
|
|
|
596
596
|
host_settings = [
|
|
597
597
|
{
|
|
598
|
-
'url': "
|
|
598
|
+
'url': "https://api.sandbox.dana.id",
|
|
599
599
|
'description': "No description provided",
|
|
600
600
|
}
|
|
601
601
|
] if (self.api_key["DANA_ENV"] == Env.SANDBOX or self.api_key["ENV"] == Env.SANDBOX) else [
|
dana/webhook/webhook.py
CHANGED
|
@@ -25,7 +25,7 @@ from cryptography.hazmat.primitives.asymmetric import padding
|
|
|
25
25
|
|
|
26
26
|
from dana.webhook.finish_notify_request import FinishNotifyRequest
|
|
27
27
|
|
|
28
|
-
# Sandbox gateway public key used for webhook signature verification when DANA_ENV/ENV is sandbox.
|
|
28
|
+
# Sandbox gateway public key used for webhook signature verification only when DANA_ENV/ENV is explicitly sandbox.
|
|
29
29
|
SANDBOX_WEBHOOK_PUBLIC_KEY = """-----BEGIN PUBLIC KEY-----
|
|
30
30
|
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnaKVGRbin4Wh4KN35OPh
|
|
31
31
|
ytJBjYTz7QZKSZjmHfiHxFmulfT87rta+IvGJ0rCBgg+1EtKk1hX8G5gPGJs1htJ
|
|
@@ -37,9 +37,41 @@ X6JV1OSST1C9sbPGzMHZ8AGB51BM0mok7davD/5irUk+f0C25OgzkwtxAt80dkDo
|
|
|
37
37
|
-----END PUBLIC KEY-----"""
|
|
38
38
|
|
|
39
39
|
|
|
40
|
+
def resolve_webhook_key_content(public_key=None, public_key_path=None) -> str:
|
|
41
|
+
"""
|
|
42
|
+
Selects the webhook public key content.
|
|
43
|
+
|
|
44
|
+
The sandbox key is used only when the environment is explicitly sandbox
|
|
45
|
+
(first non-empty of DANA_ENV, ENV, trimmed and lower-cased). In any other
|
|
46
|
+
case, including when neither variable is set, the supplied key is used:
|
|
47
|
+
public_key_path first, then public_key.
|
|
48
|
+
|
|
49
|
+
Raises:
|
|
50
|
+
ValueError: If no key is available or the key file cannot be read.
|
|
51
|
+
"""
|
|
52
|
+
env = (os.getenv("DANA_ENV") or os.getenv("ENV") or "").strip().lower()
|
|
53
|
+
if env == "sandbox":
|
|
54
|
+
return SANDBOX_WEBHOOK_PUBLIC_KEY
|
|
55
|
+
if public_key_path:
|
|
56
|
+
try:
|
|
57
|
+
return Path(public_key_path).read_text().strip()
|
|
58
|
+
except Exception as e:
|
|
59
|
+
raise ValueError(f"Failed to read key from file path '{public_key_path}': {e}")
|
|
60
|
+
if public_key:
|
|
61
|
+
return public_key.strip()
|
|
62
|
+
raise ValueError(
|
|
63
|
+
"Either 'public_key' or 'public_key_path' must be provided. "
|
|
64
|
+
"In production, pass your DANA public key via 'public_key' or 'public_key_path'. "
|
|
65
|
+
"Set DANA_ENV=sandbox to use the built-in sandbox key."
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
|
|
40
69
|
class WebhookParser:
|
|
41
70
|
"""
|
|
42
|
-
Verifies incoming webhook signatures and parse webhook request into FinishNotifyRequest object
|
|
71
|
+
Verifies incoming webhook signatures and parse webhook request into FinishNotifyRequest object.
|
|
72
|
+
|
|
73
|
+
The built-in sandbox key is used only when DANA_ENV (or ENV) is explicitly "sandbox";
|
|
74
|
+
otherwise the supplied public_key_path / public_key is required.
|
|
43
75
|
"""
|
|
44
76
|
def __init__(self, public_key: str = None, public_key_path: str = None):
|
|
45
77
|
"""
|
|
@@ -48,23 +80,13 @@ class WebhookParser:
|
|
|
48
80
|
public_key (str, optional): The public key as a string. Defaults to None.
|
|
49
81
|
public_key_path (str, optional): Path to the public key PEM file. Defaults to None.
|
|
50
82
|
If provided, this will be prioritized over public_key.
|
|
83
|
+
When DANA_ENV (or ENV) is "sandbox", the built-in sandbox key is used and both
|
|
84
|
+
arguments are ignored. For any other value, including unset, one of them is required.
|
|
51
85
|
Raises:
|
|
52
|
-
ValueError: If
|
|
86
|
+
ValueError: If no key is available (and the environment is not sandbox),
|
|
53
87
|
if the key file cannot be read, or if the key format is invalid.
|
|
54
88
|
"""
|
|
55
|
-
key_input_content =
|
|
56
|
-
env = (os.getenv("DANA_ENV") or os.getenv("ENV") or "").strip().lower()
|
|
57
|
-
if env == "sandbox" or env == "":
|
|
58
|
-
key_input_content = SANDBOX_WEBHOOK_PUBLIC_KEY
|
|
59
|
-
elif public_key_path:
|
|
60
|
-
try:
|
|
61
|
-
key_input_content = Path(public_key_path).read_text().strip()
|
|
62
|
-
except Exception as e:
|
|
63
|
-
raise ValueError(f"Failed to read key from file path '{public_key_path}': {e}")
|
|
64
|
-
elif public_key:
|
|
65
|
-
key_input_content = public_key.strip()
|
|
66
|
-
else:
|
|
67
|
-
raise ValueError("Either 'public_key' or 'public_key_path' must be provided.")
|
|
89
|
+
key_input_content = resolve_webhook_key_content(public_key, public_key_path)
|
|
68
90
|
|
|
69
91
|
if not key_input_content:
|
|
70
92
|
raise ValueError("Key content is empty.")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dana-python
|
|
3
|
-
Version:
|
|
3
|
+
Version: 3.0.0
|
|
4
4
|
Summary: API Client (SDK) for DANA APIs based on https://dashboard.dana.id/api-docs
|
|
5
5
|
Author-email: DANA Package Manager <package-manager@dana.id>
|
|
6
6
|
Maintainer-email: DANA Package Manager <package-manager@dana.id>
|
|
@@ -8,19 +8,16 @@ License-Expression: Apache-2.0
|
|
|
8
8
|
Project-URL: homepage, https://dashboard.dana.id/api-docs
|
|
9
9
|
Project-URL: repository, https://github.com/dana-id/dana-python
|
|
10
10
|
Keywords: DANA,DANA ID Docs,DANA SDK,DANA Python,DANA API Client,DANA Python API Client,DANA Python SDK
|
|
11
|
-
Requires-Python:
|
|
11
|
+
Requires-Python: >=3.10
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
13
|
License-File: LICENSE
|
|
14
|
-
Requires-Dist: annotated-types
|
|
15
|
-
Requires-Dist:
|
|
16
|
-
Requires-Dist: cryptography<46.0.0,>=44.0.2
|
|
17
|
-
Requires-Dist: pycparser==2.23
|
|
14
|
+
Requires-Dist: annotated-types>=0.7.0
|
|
15
|
+
Requires-Dist: cryptography>=50.0.0
|
|
18
16
|
Requires-Dist: pydantic<3.0.0,>=2.10.6
|
|
19
17
|
Requires-Dist: pydantic-core<3.0.0,>=2.27.2
|
|
20
|
-
Requires-Dist: python-dateutil
|
|
21
|
-
Requires-Dist: six==1.17.0
|
|
18
|
+
Requires-Dist: python-dateutil>=2.9.0.post0
|
|
22
19
|
Requires-Dist: typing-extensions<5.0.0,>=4.12.2
|
|
23
|
-
Requires-Dist: urllib3<3.0.0,>=2.
|
|
20
|
+
Requires-Dist: urllib3<3.0.0,>=2.8.0
|
|
24
21
|
Dynamic: license-file
|
|
25
22
|
|
|
26
23
|
# dana-python
|
|
@@ -62,7 +59,7 @@ Here is the link: https://github.com/dana-id/uat-script.
|
|
|
62
59
|
|
|
63
60
|
## Requirements.
|
|
64
61
|
|
|
65
|
-
Python 3.9.1
|
|
62
|
+
Python 3.10+ (patched releases: 3.11.17, 3.12.15, 3.13.17, 3.14.9, 3.15.1 or later)
|
|
66
63
|
|
|
67
64
|
## Installation & Usage
|
|
68
65
|
### pip install
|
|
@@ -152,7 +152,7 @@ dana/utils/models.py,sha256=5MYKKkZjO76k-hmrlK8S_LR1jbFRHQBAfZKmyMciX0I,1718
|
|
|
152
152
|
dana/utils/open_api_configuration.py,sha256=IQfn3c7Zs4dqOOrm1tKWBoTRdCus2alFnzRL3Yjf5ec,14805
|
|
153
153
|
dana/utils/open_api_header.py,sha256=uYUpmnnO5PI2tu30LNx3hE6fI-NOc2VMkc1P3G9xZpw,9537
|
|
154
154
|
dana/utils/script.py,sha256=zel7LB6GmIGIFyaegYdtmGZj-0tcwe6xuTXvGz-8vLw,2480
|
|
155
|
-
dana/utils/snap_configuration.py,sha256=
|
|
155
|
+
dana/utils/snap_configuration.py,sha256=QBdAELaNQLT-BCRrZbQMaGse-WPMXWZXWJQIckyXTc4,21534
|
|
156
156
|
dana/utils/snap_header.py,sha256=QE0Kbna1f2WEH5MknLKkWgLNbzdWEjF36DngKBcdXuA,13393
|
|
157
157
|
dana/utils/url.py,sha256=wCDthoodIDANoth6SqSoiIdNwc-hJLNjFBdf_fSjU_4,1965
|
|
158
158
|
dana/webhook/__init__.py,sha256=PGG-SGs96pn8aBTVhR9Xg4-DkIvsIRIdZfV57ZG1FwI,626
|
|
@@ -163,7 +163,7 @@ dana/webhook/finish_notify_response.py,sha256=9bHXP2TdU02GkOF8F-M6qF6ox-x2wBz6Nr
|
|
|
163
163
|
dana/webhook/money.py,sha256=4o0oPAf7LnpVHX45yhqmXs5tg5PKlJ2B-OqfHi4aGQM,3413
|
|
164
164
|
dana/webhook/pay_option_info.py,sha256=_IA3X04ZIBYsVfoe31w4tYvjz_klKb9GEWDXBoROrF4,8739
|
|
165
165
|
dana/webhook/shop_info.py,sha256=a7ZsvGA10hao9qeazp5H6jjNt9J_uz9A6cdD5TZSNsU,4722
|
|
166
|
-
dana/webhook/webhook.py,sha256=
|
|
166
|
+
dana/webhook/webhook.py,sha256=abvxl0pESAvNSrm-cFKjXyquRfvSqrwC97VKTMjVWR0,15900
|
|
167
167
|
dana/widget/__init__.py,sha256=_1fR4wVGZVf1d5G_ogKEEQkJ2fc6z_Zv4qDTlALTCHg,593
|
|
168
168
|
dana/widget/v1/__init__.py,sha256=ibJjQQ3NDAK_UwYZKHZzBVAScX4mkQixi_LD3RGTr4U,5576
|
|
169
169
|
dana/widget/v1/custom_validation.py,sha256=XqQLJu3Dh5XdUpG5eXXSq8dYVymha3vDdpkoKjJ0E7U,7028
|
|
@@ -229,8 +229,8 @@ dana/widget/v1/models/virtual_account_info.py,sha256=qCFyTqwOFY0KwawiQhRfWYwv0Hv
|
|
|
229
229
|
dana/widget/v1/models/widget_payment_request.py,sha256=KZPOauNqtDvtETLSAgkfgLagOiX2H5KaOGroSbRKCAg,8469
|
|
230
230
|
dana/widget/v1/models/widget_payment_request_additional_info.py,sha256=Qa4Akl-KxeBdh3ITnb0_LxVmgZA_YJsYgW_MHKTHj1A,6273
|
|
231
231
|
dana/widget/v1/models/widget_payment_response.py,sha256=KNfxpyOeNjyRG8aNRzTCaY1W5i0PgSVj3x2O8I6b_kE,6037
|
|
232
|
-
dana_python-
|
|
233
|
-
dana_python-
|
|
234
|
-
dana_python-
|
|
235
|
-
dana_python-
|
|
236
|
-
dana_python-
|
|
232
|
+
dana_python-3.0.0.dist-info/licenses/LICENSE,sha256=7CXCr_1HV_P6dPKoffVsU3lk2eVjnRacBDnQIeJMgFc,10232
|
|
233
|
+
dana_python-3.0.0.dist-info/METADATA,sha256=2fhWF0Jl7Bm6DAZbVCbvDY4FNkIU6mrhOjaO3zIOU8k,5545
|
|
234
|
+
dana_python-3.0.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
235
|
+
dana_python-3.0.0.dist-info/top_level.txt,sha256=uvbw-Siay0DC-rXYYx11_k0lqDnrOl5tFeSkE-3Mb8I,5
|
|
236
|
+
dana_python-3.0.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|