sockudo-http-python 2.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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Sockudo
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,191 @@
1
+ Metadata-Version: 2.4
2
+ Name: sockudo-http-python
3
+ Version: 2.0.0
4
+ Summary: High-performance Python HTTP server SDK for Sockudo
5
+ Author: Sockudo
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/sockudo/sockudo/tree/master/server-sdks/sockudo-http-python
8
+ Project-URL: Repository, https://github.com/sockudo/sockudo
9
+ Project-URL: Issues, https://github.com/sockudo/sockudo/issues
10
+ Requires-Python: >=3.9
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Requires-Dist: httpx[http2]>=0.27.0
14
+ Requires-Dist: PyNaCl>=1.5.0
15
+ Provides-Extra: dev
16
+ Requires-Dist: build>=1.2.2; extra == "dev"
17
+ Requires-Dist: pytest>=8.0.0; extra == "dev"
18
+ Requires-Dist: pytest-asyncio>=0.23.0; extra == "dev"
19
+ Requires-Dist: ruff>=0.9.0; extra == "dev"
20
+ Requires-Dist: twine>=6.0.0; extra == "dev"
21
+ Dynamic: license-file
22
+
23
+ # Sockudo Python HTTP Server SDK
24
+
25
+ High-performance Python server SDK for the Sockudo HTTP API. It publishes events, signs channel and user authentication payloads, validates webhooks, queries channel state, reads durable history, mutates versioned messages, and manages annotations.
26
+
27
+ ## Features
28
+
29
+ - Sync and asyncio clients: `Sockudo` and `AsyncSockudo`
30
+ - Persistent HTTP connection pooling via `httpx`, with HTTP/2 enabled by default
31
+ - Pusher-compatible signed REST requests
32
+ - Single, multi-channel, and batch publishing
33
+ - Explicit and automatic idempotency keys for safe publish retries
34
+ - Private, presence, user, and webhook authentication helpers
35
+ - Channel state, presence users, durable history, and presence history APIs
36
+ - Versioned message APIs: get, versions, update, delete, append
37
+ - Annotation APIs: publish, list, delete
38
+ - Operator controls for history reset/purge and presence-history reset
39
+ - End-to-end encrypted channel auth, publish, batch publish, and webhook decrypt support for `private-encrypted-*` channels
40
+
41
+ ## Install
42
+
43
+ For apps, install the published package:
44
+
45
+ ```bash
46
+ pip install sockudo-http-python
47
+ ```
48
+
49
+ For local monorepo development, install from the local path:
50
+
51
+ ```bash
52
+ git clone https://github.com/sockudo/sockudo.git
53
+ pip install -e sockudo/server-sdks/sockudo-http-python
54
+ ```
55
+
56
+ For local development from this monorepo:
57
+
58
+ ```bash
59
+ pip install -e server-sdks/sockudo-http-python[dev]
60
+ ```
61
+
62
+ ## Quick Start
63
+
64
+ ```python
65
+ from sockudo_http import Config, Sockudo
66
+
67
+ sockudo = Sockudo(Config(app_id="app-id", key="app-key", secret="app-secret", host="127.0.0.1", port=6001))
68
+
69
+ result = sockudo.trigger("orders", "order.created", {"id": "ord_123"})
70
+ assert result.ok
71
+ sockudo.close()
72
+ ```
73
+
74
+ Async:
75
+
76
+ ```python
77
+ from sockudo_http_python import AsyncSockudo, SockudoOptions
78
+
79
+ async with AsyncSockudo(
80
+ "app-id",
81
+ "app-key",
82
+ "app-secret",
83
+ options=SockudoOptions(host="127.0.0.1", port=6001),
84
+ ) as sockudo:
85
+ await sockudo.trigger("orders", "order.created", {"id": "ord_123"})
86
+ ```
87
+
88
+ ## Idempotent Publishing
89
+
90
+ ```python
91
+ from sockudo_http_python import TriggerOptions
92
+
93
+ sockudo.trigger(
94
+ "orders",
95
+ "order.created",
96
+ {"id": "ord_123"},
97
+ TriggerOptions(idempotency_key="order-created-ord_123"),
98
+ )
99
+
100
+ sockudo.trigger("orders", "order.created", {"id": "ord_124"}, TriggerOptions(idempotency_key=True))
101
+ ```
102
+
103
+ Set `SockudoOptions(auto_idempotency=True)` to generate keys for publish and batch publish calls that omit one.
104
+
105
+ Target a single user channel:
106
+
107
+ ```python
108
+ sockudo.send_to_user("user-123", "notice", {"body": "hello"})
109
+ ```
110
+
111
+ ## Authentication Helpers
112
+
113
+ ```python
114
+ from sockudo_http_python import PresenceUser
115
+
116
+ private_body = sockudo.authenticate("123.456", "private-orders")
117
+
118
+ presence_body = sockudo.authenticate(
119
+ "123.456",
120
+ "presence-room",
121
+ PresenceUser("user-1", {"name": "Ada"}),
122
+ )
123
+
124
+ user_body = sockudo.authenticate_user("123.456", {"id": "user-1", "name": "Ada"})
125
+ ```
126
+
127
+ Encrypted channel auth responses include `shared_secret` when `encryption_master_key_base64` is configured:
128
+
129
+ ```python
130
+ encrypted = Sockudo(
131
+ "app-id",
132
+ "app-key",
133
+ "app-secret",
134
+ encryption_master_key_base64="base64-encoded-32-byte-key",
135
+ )
136
+
137
+ body = encrypted.authenticate("123.456", "private-encrypted-room")
138
+ ```
139
+
140
+ ## Channel And History APIs
141
+
142
+ ```python
143
+ from sockudo_http_python import ChannelsParams, HistoryParams, PresenceHistoryParams
144
+
145
+ sockudo.list_channels(ChannelsParams(filter_by_prefix="presence-", info=["subscription_count", "user_count"]))
146
+ sockudo.get_channel_users("presence-room")
147
+ sockudo.get_channel_history("orders", HistoryParams(limit=50, direction="newest_first"))
148
+ sockudo.get_channel_presence_history("presence-room", PresenceHistoryParams(limit=50))
149
+ ```
150
+
151
+ ## Versioned Messages And Annotations
152
+
153
+ ```python
154
+ from sockudo_http_python import MessageMutation, PublishAnnotationRequest
155
+
156
+ sockudo.get_message("orders", "msg:1")
157
+ sockudo.get_message_versions("orders", "msg:1")
158
+ sockudo.update_message("orders", "msg:1", MessageMutation(data={"status": "paid"}))
159
+ sockudo.append_message("orders", "msg:1", " appended text")
160
+ sockudo.delete_message("orders", "msg:1", MessageMutation(description="moderated"))
161
+
162
+ sockudo.publish_annotation(
163
+ "orders",
164
+ "msg:1",
165
+ PublishAnnotationRequest(type="reactions:distinct.v1", name="like", client_id="user-1", count=1),
166
+ )
167
+ sockudo.list_annotations("orders", "msg:1")
168
+ ```
169
+
170
+ ## Webhooks
171
+
172
+ ```python
173
+ validity = sockudo.validate_webhook_signature(x_pusher_key, x_pusher_signature, raw_body)
174
+ webhook = sockudo.parse_webhook(x_pusher_key, x_pusher_signature, raw_body)
175
+ ```
176
+
177
+ If a webhook contains encrypted channel events and the client has an encryption master key, `parse_webhook` decrypts those event payloads.
178
+
179
+ ## Signed URIs
180
+
181
+ ```python
182
+ uri = sockudo.signed_uri("GET", "/apps/app-id/channels", parameters={"filter_by_prefix": "presence-"})
183
+ ```
184
+
185
+ The signing format matches Sockudo/Pusher REST auth: `auth_key`, `auth_timestamp`, `auth_version`, optional `body_md5`, and `auth_signature` over `{METHOD}\n{PATH}\n{SORTED_QUERY}`.
186
+
187
+ ## URL Configuration
188
+
189
+ ```python
190
+ sockudo = Sockudo.from_url("http://app-key:app-secret@127.0.0.1:6001/apps/app-id")
191
+ ```
@@ -0,0 +1,169 @@
1
+ # Sockudo Python HTTP Server SDK
2
+
3
+ High-performance Python server SDK for the Sockudo HTTP API. It publishes events, signs channel and user authentication payloads, validates webhooks, queries channel state, reads durable history, mutates versioned messages, and manages annotations.
4
+
5
+ ## Features
6
+
7
+ - Sync and asyncio clients: `Sockudo` and `AsyncSockudo`
8
+ - Persistent HTTP connection pooling via `httpx`, with HTTP/2 enabled by default
9
+ - Pusher-compatible signed REST requests
10
+ - Single, multi-channel, and batch publishing
11
+ - Explicit and automatic idempotency keys for safe publish retries
12
+ - Private, presence, user, and webhook authentication helpers
13
+ - Channel state, presence users, durable history, and presence history APIs
14
+ - Versioned message APIs: get, versions, update, delete, append
15
+ - Annotation APIs: publish, list, delete
16
+ - Operator controls for history reset/purge and presence-history reset
17
+ - End-to-end encrypted channel auth, publish, batch publish, and webhook decrypt support for `private-encrypted-*` channels
18
+
19
+ ## Install
20
+
21
+ For apps, install the published package:
22
+
23
+ ```bash
24
+ pip install sockudo-http-python
25
+ ```
26
+
27
+ For local monorepo development, install from the local path:
28
+
29
+ ```bash
30
+ git clone https://github.com/sockudo/sockudo.git
31
+ pip install -e sockudo/server-sdks/sockudo-http-python
32
+ ```
33
+
34
+ For local development from this monorepo:
35
+
36
+ ```bash
37
+ pip install -e server-sdks/sockudo-http-python[dev]
38
+ ```
39
+
40
+ ## Quick Start
41
+
42
+ ```python
43
+ from sockudo_http import Config, Sockudo
44
+
45
+ sockudo = Sockudo(Config(app_id="app-id", key="app-key", secret="app-secret", host="127.0.0.1", port=6001))
46
+
47
+ result = sockudo.trigger("orders", "order.created", {"id": "ord_123"})
48
+ assert result.ok
49
+ sockudo.close()
50
+ ```
51
+
52
+ Async:
53
+
54
+ ```python
55
+ from sockudo_http_python import AsyncSockudo, SockudoOptions
56
+
57
+ async with AsyncSockudo(
58
+ "app-id",
59
+ "app-key",
60
+ "app-secret",
61
+ options=SockudoOptions(host="127.0.0.1", port=6001),
62
+ ) as sockudo:
63
+ await sockudo.trigger("orders", "order.created", {"id": "ord_123"})
64
+ ```
65
+
66
+ ## Idempotent Publishing
67
+
68
+ ```python
69
+ from sockudo_http_python import TriggerOptions
70
+
71
+ sockudo.trigger(
72
+ "orders",
73
+ "order.created",
74
+ {"id": "ord_123"},
75
+ TriggerOptions(idempotency_key="order-created-ord_123"),
76
+ )
77
+
78
+ sockudo.trigger("orders", "order.created", {"id": "ord_124"}, TriggerOptions(idempotency_key=True))
79
+ ```
80
+
81
+ Set `SockudoOptions(auto_idempotency=True)` to generate keys for publish and batch publish calls that omit one.
82
+
83
+ Target a single user channel:
84
+
85
+ ```python
86
+ sockudo.send_to_user("user-123", "notice", {"body": "hello"})
87
+ ```
88
+
89
+ ## Authentication Helpers
90
+
91
+ ```python
92
+ from sockudo_http_python import PresenceUser
93
+
94
+ private_body = sockudo.authenticate("123.456", "private-orders")
95
+
96
+ presence_body = sockudo.authenticate(
97
+ "123.456",
98
+ "presence-room",
99
+ PresenceUser("user-1", {"name": "Ada"}),
100
+ )
101
+
102
+ user_body = sockudo.authenticate_user("123.456", {"id": "user-1", "name": "Ada"})
103
+ ```
104
+
105
+ Encrypted channel auth responses include `shared_secret` when `encryption_master_key_base64` is configured:
106
+
107
+ ```python
108
+ encrypted = Sockudo(
109
+ "app-id",
110
+ "app-key",
111
+ "app-secret",
112
+ encryption_master_key_base64="base64-encoded-32-byte-key",
113
+ )
114
+
115
+ body = encrypted.authenticate("123.456", "private-encrypted-room")
116
+ ```
117
+
118
+ ## Channel And History APIs
119
+
120
+ ```python
121
+ from sockudo_http_python import ChannelsParams, HistoryParams, PresenceHistoryParams
122
+
123
+ sockudo.list_channels(ChannelsParams(filter_by_prefix="presence-", info=["subscription_count", "user_count"]))
124
+ sockudo.get_channel_users("presence-room")
125
+ sockudo.get_channel_history("orders", HistoryParams(limit=50, direction="newest_first"))
126
+ sockudo.get_channel_presence_history("presence-room", PresenceHistoryParams(limit=50))
127
+ ```
128
+
129
+ ## Versioned Messages And Annotations
130
+
131
+ ```python
132
+ from sockudo_http_python import MessageMutation, PublishAnnotationRequest
133
+
134
+ sockudo.get_message("orders", "msg:1")
135
+ sockudo.get_message_versions("orders", "msg:1")
136
+ sockudo.update_message("orders", "msg:1", MessageMutation(data={"status": "paid"}))
137
+ sockudo.append_message("orders", "msg:1", " appended text")
138
+ sockudo.delete_message("orders", "msg:1", MessageMutation(description="moderated"))
139
+
140
+ sockudo.publish_annotation(
141
+ "orders",
142
+ "msg:1",
143
+ PublishAnnotationRequest(type="reactions:distinct.v1", name="like", client_id="user-1", count=1),
144
+ )
145
+ sockudo.list_annotations("orders", "msg:1")
146
+ ```
147
+
148
+ ## Webhooks
149
+
150
+ ```python
151
+ validity = sockudo.validate_webhook_signature(x_pusher_key, x_pusher_signature, raw_body)
152
+ webhook = sockudo.parse_webhook(x_pusher_key, x_pusher_signature, raw_body)
153
+ ```
154
+
155
+ If a webhook contains encrypted channel events and the client has an encryption master key, `parse_webhook` decrypts those event payloads.
156
+
157
+ ## Signed URIs
158
+
159
+ ```python
160
+ uri = sockudo.signed_uri("GET", "/apps/app-id/channels", parameters={"filter_by_prefix": "presence-"})
161
+ ```
162
+
163
+ The signing format matches Sockudo/Pusher REST auth: `auth_key`, `auth_timestamp`, `auth_version`, optional `body_md5`, and `auth_signature` over `{METHOD}\n{PATH}\n{SORTED_QUERY}`.
164
+
165
+ ## URL Configuration
166
+
167
+ ```python
168
+ sockudo = Sockudo.from_url("http://app-key:app-secret@127.0.0.1:6001/apps/app-id")
169
+ ```
@@ -0,0 +1,41 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "sockudo-http-python"
7
+ version = "2.0.0"
8
+ description = "High-performance Python HTTP server SDK for Sockudo"
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ license = "MIT"
12
+ license-files = ["LICENSE"]
13
+ authors = [{ name = "Sockudo" }]
14
+ dependencies = [
15
+ "httpx[http2]>=0.27.0",
16
+ "PyNaCl>=1.5.0",
17
+ ]
18
+
19
+ [project.urls]
20
+ Homepage = "https://github.com/sockudo/sockudo/tree/master/server-sdks/sockudo-http-python"
21
+ Repository = "https://github.com/sockudo/sockudo"
22
+ Issues = "https://github.com/sockudo/sockudo/issues"
23
+
24
+ [project.optional-dependencies]
25
+ dev = [
26
+ "build>=1.2.2",
27
+ "pytest>=8.0.0",
28
+ "pytest-asyncio>=0.23.0",
29
+ "ruff>=0.9.0",
30
+ "twine>=6.0.0",
31
+ ]
32
+
33
+ [tool.setuptools.package-dir]
34
+ "" = "src"
35
+
36
+ [tool.setuptools.packages.find]
37
+ where = ["src"]
38
+
39
+ [tool.pytest.ini_options]
40
+ testpaths = ["tests"]
41
+ asyncio_mode = "auto"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1 @@
1
+ from sockudo_http_python import * # noqa: F401,F403
@@ -0,0 +1,61 @@
1
+ from .client import (
2
+ AnnotationEventsParams,
3
+ AsyncSockudo,
4
+ AuthData,
5
+ Config,
6
+ ChannelParams,
7
+ ChannelsParams,
8
+ Event,
9
+ HistoryParams,
10
+ MessageExtras,
11
+ MessageMutation,
12
+ MessageVersionsParams,
13
+ PresenceHistoryParams,
14
+ PresenceSnapshotParams,
15
+ PresenceUser,
16
+ PushCursorParams,
17
+ PushSubscriptionParams,
18
+ PublishAnnotationRequest,
19
+ Result,
20
+ Sockudo,
21
+ SockudoError,
22
+ SockudoOptions,
23
+ Status,
24
+ TriggerOptions,
25
+ Validity,
26
+ Webhook,
27
+ WebhookEvent,
28
+ body_md5,
29
+ sign,
30
+ )
31
+
32
+ __all__ = [
33
+ "AnnotationEventsParams",
34
+ "AsyncSockudo",
35
+ "AuthData",
36
+ "Config",
37
+ "ChannelParams",
38
+ "ChannelsParams",
39
+ "Event",
40
+ "HistoryParams",
41
+ "MessageExtras",
42
+ "MessageMutation",
43
+ "MessageVersionsParams",
44
+ "PresenceHistoryParams",
45
+ "PresenceSnapshotParams",
46
+ "PresenceUser",
47
+ "PushCursorParams",
48
+ "PushSubscriptionParams",
49
+ "PublishAnnotationRequest",
50
+ "Result",
51
+ "Sockudo",
52
+ "SockudoError",
53
+ "SockudoOptions",
54
+ "Status",
55
+ "TriggerOptions",
56
+ "Validity",
57
+ "Webhook",
58
+ "WebhookEvent",
59
+ "body_md5",
60
+ "sign",
61
+ ]