nathbrokrestsdk 1.0.0__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.
- nathbrokrestsdk-1.0.0/LICENSE +21 -0
- nathbrokrestsdk-1.0.0/PKG-INFO +124 -0
- nathbrokrestsdk-1.0.0/README.md +110 -0
- nathbrokrestsdk-1.0.0/pyproject.toml +23 -0
- nathbrokrestsdk-1.0.0/setup.cfg +4 -0
- nathbrokrestsdk-1.0.0/src/nathbrokrestsdk/auth/__init__.py +4 -0
- nathbrokrestsdk-1.0.0/src/nathbrokrestsdk/auth/exceptions.py +7 -0
- nathbrokrestsdk-1.0.0/src/nathbrokrestsdk/auth/request.py +417 -0
- nathbrokrestsdk-1.0.0/src/nathbrokrestsdk/chat/__init__.py +4 -0
- nathbrokrestsdk-1.0.0/src/nathbrokrestsdk/chat/client.py +205 -0
- nathbrokrestsdk-1.0.0/src/nathbrokrestsdk/chat/crypto.py +306 -0
- nathbrokrestsdk-1.0.0/src/nathbrokrestsdk/cloud/__init__.py +3 -0
- nathbrokrestsdk-1.0.0/src/nathbrokrestsdk/cloud/client.py +129 -0
- nathbrokrestsdk-1.0.0/src/nathbrokrestsdk/dde/__init__.py +3 -0
- nathbrokrestsdk-1.0.0/src/nathbrokrestsdk/dde/client.py +76 -0
- nathbrokrestsdk-1.0.0/src/nathbrokrestsdk/mail/__init__.py +3 -0
- nathbrokrestsdk-1.0.0/src/nathbrokrestsdk/mail/client.py +75 -0
- nathbrokrestsdk-1.0.0/src/nathbrokrestsdk.egg-info/PKG-INFO +124 -0
- nathbrokrestsdk-1.0.0/src/nathbrokrestsdk.egg-info/SOURCES.txt +24 -0
- nathbrokrestsdk-1.0.0/src/nathbrokrestsdk.egg-info/dependency_links.txt +1 -0
- nathbrokrestsdk-1.0.0/src/nathbrokrestsdk.egg-info/requires.txt +2 -0
- nathbrokrestsdk-1.0.0/src/nathbrokrestsdk.egg-info/top_level.txt +1 -0
- nathbrokrestsdk-1.0.0/tests/test_auth_encryption.py +277 -0
- nathbrokrestsdk-1.0.0/tests/test_chat_crypto.py +253 -0
- nathbrokrestsdk-1.0.0/tests/test_client.py +120 -0
- nathbrokrestsdk-1.0.0/tests/test_mail_client.py +92 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Nathbrok
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: nathbrokrestsdk
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Python SDK for Nathbrok file, chat, and server SSO APIs.
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Project-URL: Homepage, https://docs.nathbrok.com/sdk/v1/
|
|
7
|
+
Project-URL: Issues, https://docs.nathbrok.com/sdk/v1/issues/
|
|
8
|
+
Requires-Python: >=3.10
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Requires-Dist: cryptography>=41
|
|
12
|
+
Requires-Dist: requests>=2.31
|
|
13
|
+
Dynamic: license-file
|
|
14
|
+
|
|
15
|
+
# Nathbrok REST SDK
|
|
16
|
+
|
|
17
|
+
`nathbrokrestsdk` is a Python client library for the Nathbrok REST APIs. It
|
|
18
|
+
provides HMAC request signing, optional encrypted server requests, and clients
|
|
19
|
+
for chat, cloud storage, mail, and data encryption.
|
|
20
|
+
|
|
21
|
+
## Requirements
|
|
22
|
+
|
|
23
|
+
- Python 3.10 or later
|
|
24
|
+
- A Nathbrok server access key ID, one-time access key, and signing secret
|
|
25
|
+
|
|
26
|
+
## Install
|
|
27
|
+
|
|
28
|
+
From this directory, install the package with:
|
|
29
|
+
|
|
30
|
+
```shell
|
|
31
|
+
python -m pip install .
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
The package installs its runtime dependencies (`requests` and `cryptography`).
|
|
35
|
+
|
|
36
|
+
## Initialize authentication
|
|
37
|
+
|
|
38
|
+
Keep credentials outside source control. The initialization call validates the
|
|
39
|
+
access key and retrieves the server's public encryption key.
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
import os
|
|
43
|
+
|
|
44
|
+
from nathbrokrestsdk.auth import Auth
|
|
45
|
+
|
|
46
|
+
auth = Auth()
|
|
47
|
+
auth.initialize(
|
|
48
|
+
access_key_id=os.environ["NATHBROK_ACCESS_KEY_ID"],
|
|
49
|
+
access_key=os.environ["NATHBROK_ACCESS_KEY"],
|
|
50
|
+
secret_key=os.environ["NATHBROK_SECRET_KEY"],
|
|
51
|
+
)
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
`Auth` signs requests with the configured secret. Calls that send encrypted
|
|
55
|
+
requests use the server key fetched during initialization. API failures are
|
|
56
|
+
raised as `NathbrokAPIError`:
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
from nathbrokrestsdk.auth import NathbrokAPIError
|
|
60
|
+
|
|
61
|
+
try:
|
|
62
|
+
sso_url = auth.create_sso_url("user@example.com")
|
|
63
|
+
except NathbrokAPIError as exc:
|
|
64
|
+
print(exc.status_code, exc)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
`Auth` also accepts a custom `base_url` and `timeout` when constructing it.
|
|
68
|
+
Use HTTPS outside local development.
|
|
69
|
+
|
|
70
|
+
## Chat
|
|
71
|
+
|
|
72
|
+
Chat operations use local end-to-end encryption for room keys and message
|
|
73
|
+
content. Each participant must have usable public-key material registered;
|
|
74
|
+
the creator unlocks their private key locally with their passphrase.
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
from nathbrokrestsdk.chat import ChatClient
|
|
78
|
+
|
|
79
|
+
chat = ChatClient(auth)
|
|
80
|
+
room = chat.create_room(
|
|
81
|
+
name="Project discussion",
|
|
82
|
+
users=["colleague@example.com"],
|
|
83
|
+
passphrase=os.environ["NATHBROK_CHAT_PASSPHRASE"],
|
|
84
|
+
user="owner@nathlink",
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
chat.send_message(
|
|
88
|
+
message=["Hello from the SDK"],
|
|
89
|
+
room_id=room["room_id"],
|
|
90
|
+
sender="owner@nathlink",
|
|
91
|
+
passphrase=os.environ["NATHBROK_CHAT_PASSPHRASE"],
|
|
92
|
+
)
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
`ChatClient` also provides methods to unlock rooms, encrypt/decrypt messages,
|
|
96
|
+
and delete rooms or messages. Keep passphrases secure; they are used locally to
|
|
97
|
+
unlock key material and should not be sent to the API.
|
|
98
|
+
|
|
99
|
+
## Other clients
|
|
100
|
+
|
|
101
|
+
- `nathbrokrestsdk.cloud.CloudClient` uploads and manages bucket files.
|
|
102
|
+
- `nathbrokrestsdk.mail.MailClient` sends email through an authorized mailbox.
|
|
103
|
+
- `nathbrokrestsdk.dde.DDEClient` requests file and data encryption/decryption.
|
|
104
|
+
|
|
105
|
+
`MailClient` accepts an initialized `Auth` instance:
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
from nathbrokrestsdk.mail import MailClient
|
|
109
|
+
|
|
110
|
+
mail = MailClient(auth)
|
|
111
|
+
result = mail.send_email(
|
|
112
|
+
{"subject": "Hello", "body_text": "Sent with Nathbrok."},
|
|
113
|
+
mailbox="sender@example.com",
|
|
114
|
+
to="recipient@example.com",
|
|
115
|
+
)
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
All clients return decoded JSON response data. Consult the Nathbrok SDK
|
|
119
|
+
documentation for endpoint permissions and account setup:
|
|
120
|
+
<https://docs.nathbrok.com/sdk/v1/>.
|
|
121
|
+
|
|
122
|
+
## License
|
|
123
|
+
|
|
124
|
+
This project is distributed under the MIT License. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# Nathbrok REST SDK
|
|
2
|
+
|
|
3
|
+
`nathbrokrestsdk` is a Python client library for the Nathbrok REST APIs. It
|
|
4
|
+
provides HMAC request signing, optional encrypted server requests, and clients
|
|
5
|
+
for chat, cloud storage, mail, and data encryption.
|
|
6
|
+
|
|
7
|
+
## Requirements
|
|
8
|
+
|
|
9
|
+
- Python 3.10 or later
|
|
10
|
+
- A Nathbrok server access key ID, one-time access key, and signing secret
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
From this directory, install the package with:
|
|
15
|
+
|
|
16
|
+
```shell
|
|
17
|
+
python -m pip install .
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
The package installs its runtime dependencies (`requests` and `cryptography`).
|
|
21
|
+
|
|
22
|
+
## Initialize authentication
|
|
23
|
+
|
|
24
|
+
Keep credentials outside source control. The initialization call validates the
|
|
25
|
+
access key and retrieves the server's public encryption key.
|
|
26
|
+
|
|
27
|
+
```python
|
|
28
|
+
import os
|
|
29
|
+
|
|
30
|
+
from nathbrokrestsdk.auth import Auth
|
|
31
|
+
|
|
32
|
+
auth = Auth()
|
|
33
|
+
auth.initialize(
|
|
34
|
+
access_key_id=os.environ["NATHBROK_ACCESS_KEY_ID"],
|
|
35
|
+
access_key=os.environ["NATHBROK_ACCESS_KEY"],
|
|
36
|
+
secret_key=os.environ["NATHBROK_SECRET_KEY"],
|
|
37
|
+
)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
`Auth` signs requests with the configured secret. Calls that send encrypted
|
|
41
|
+
requests use the server key fetched during initialization. API failures are
|
|
42
|
+
raised as `NathbrokAPIError`:
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
from nathbrokrestsdk.auth import NathbrokAPIError
|
|
46
|
+
|
|
47
|
+
try:
|
|
48
|
+
sso_url = auth.create_sso_url("user@example.com")
|
|
49
|
+
except NathbrokAPIError as exc:
|
|
50
|
+
print(exc.status_code, exc)
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
`Auth` also accepts a custom `base_url` and `timeout` when constructing it.
|
|
54
|
+
Use HTTPS outside local development.
|
|
55
|
+
|
|
56
|
+
## Chat
|
|
57
|
+
|
|
58
|
+
Chat operations use local end-to-end encryption for room keys and message
|
|
59
|
+
content. Each participant must have usable public-key material registered;
|
|
60
|
+
the creator unlocks their private key locally with their passphrase.
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
from nathbrokrestsdk.chat import ChatClient
|
|
64
|
+
|
|
65
|
+
chat = ChatClient(auth)
|
|
66
|
+
room = chat.create_room(
|
|
67
|
+
name="Project discussion",
|
|
68
|
+
users=["colleague@example.com"],
|
|
69
|
+
passphrase=os.environ["NATHBROK_CHAT_PASSPHRASE"],
|
|
70
|
+
user="owner@nathlink",
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
chat.send_message(
|
|
74
|
+
message=["Hello from the SDK"],
|
|
75
|
+
room_id=room["room_id"],
|
|
76
|
+
sender="owner@nathlink",
|
|
77
|
+
passphrase=os.environ["NATHBROK_CHAT_PASSPHRASE"],
|
|
78
|
+
)
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
`ChatClient` also provides methods to unlock rooms, encrypt/decrypt messages,
|
|
82
|
+
and delete rooms or messages. Keep passphrases secure; they are used locally to
|
|
83
|
+
unlock key material and should not be sent to the API.
|
|
84
|
+
|
|
85
|
+
## Other clients
|
|
86
|
+
|
|
87
|
+
- `nathbrokrestsdk.cloud.CloudClient` uploads and manages bucket files.
|
|
88
|
+
- `nathbrokrestsdk.mail.MailClient` sends email through an authorized mailbox.
|
|
89
|
+
- `nathbrokrestsdk.dde.DDEClient` requests file and data encryption/decryption.
|
|
90
|
+
|
|
91
|
+
`MailClient` accepts an initialized `Auth` instance:
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
from nathbrokrestsdk.mail import MailClient
|
|
95
|
+
|
|
96
|
+
mail = MailClient(auth)
|
|
97
|
+
result = mail.send_email(
|
|
98
|
+
{"subject": "Hello", "body_text": "Sent with Nathbrok."},
|
|
99
|
+
mailbox="sender@example.com",
|
|
100
|
+
to="recipient@example.com",
|
|
101
|
+
)
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
All clients return decoded JSON response data. Consult the Nathbrok SDK
|
|
105
|
+
documentation for endpoint permissions and account setup:
|
|
106
|
+
<https://docs.nathbrok.com/sdk/v1/>.
|
|
107
|
+
|
|
108
|
+
## License
|
|
109
|
+
|
|
110
|
+
This project is distributed under the MIT License. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "nathbrokrestsdk"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "Python SDK for Nathbrok file, chat, and server SSO APIs."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
dependencies = ["cryptography>=41", "requests>=2.31"]
|
|
12
|
+
license = "MIT"
|
|
13
|
+
license-files = ["LICEN[CS]E*"]
|
|
14
|
+
|
|
15
|
+
[tool.setuptools]
|
|
16
|
+
package-dir = {"" = "src"}
|
|
17
|
+
|
|
18
|
+
[tool.setuptools.packages.find]
|
|
19
|
+
where = ["src"]
|
|
20
|
+
|
|
21
|
+
[project.urls]
|
|
22
|
+
Homepage = "https://docs.nathbrok.com/sdk/v1/"
|
|
23
|
+
Issues = "https://docs.nathbrok.com/sdk/v1/issues/"
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
class NathbrokAPIError(RuntimeError):
|
|
2
|
+
"""Raised when Nathbrok returns an unsuccessful or invalid API response."""
|
|
3
|
+
|
|
4
|
+
def __init__(self, status_code: int, detail: object) -> None:
|
|
5
|
+
self.status_code = status_code
|
|
6
|
+
self.detail = detail
|
|
7
|
+
super().__init__(f"Nathbrok API returned HTTP {status_code}: {detail}")
|