simplepush 2.2.4__tar.gz → 3.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,20 @@
1
+ # Build artifacts
2
+ dist/
3
+ build/
4
+ *.egg-info/
5
+
6
+ # Bytecode
7
+ __pycache__/
8
+ *.py[cod]
9
+
10
+ # Virtual envs
11
+ .venv/
12
+ venv/
13
+ env/
14
+
15
+ # Editors
16
+ .idea/
17
+ .vscode/
18
+
19
+ # OS
20
+ .DS_Store
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Timm Schaeuble
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,359 @@
1
+ Metadata-Version: 2.4
2
+ Name: simplepush
3
+ Version: 3.0.0
4
+ Summary: Python client for Simplepush (tasks, notifications, events, end-to-end encryption).
5
+ Project-URL: Homepage, https://simplepu.sh
6
+ Project-URL: Documentation, https://simplepu.sh/guide/python-sdk
7
+ Project-URL: Source, https://github.com/simplepush/simplepush-python
8
+ Project-URL: Issues, https://github.com/simplepush/simplepush-python/issues
9
+ Author-email: Timm Schaeuble <contact@simplepush.io>
10
+ License: MIT License
11
+
12
+ Copyright (c) 2026 Timm Schaeuble
13
+
14
+ Permission is hereby granted, free of charge, to any person obtaining a copy
15
+ of this software and associated documentation files (the "Software"), to deal
16
+ in the Software without restriction, including without limitation the rights
17
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
+ copies of the Software, and to permit persons to whom the Software is
19
+ furnished to do so, subject to the following conditions:
20
+
21
+ The above copyright notice and this permission notice shall be included in all
22
+ copies or substantial portions of the Software.
23
+
24
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30
+ SOFTWARE.
31
+ License-File: LICENSE
32
+ Keywords: actionable-notifications,approvals,automation,data-collection,end-to-end-encryption,events,forms,human-in-the-loop,low-code,mobile,no-code,notifications,push,simplepush,tasks,websocket,workflow
33
+ Classifier: Development Status :: 5 - Production/Stable
34
+ Classifier: Intended Audience :: Developers
35
+ Classifier: License :: OSI Approved :: MIT License
36
+ Classifier: Operating System :: OS Independent
37
+ Classifier: Programming Language :: Python :: 3
38
+ Classifier: Programming Language :: Python :: 3 :: Only
39
+ Classifier: Programming Language :: Python :: 3.10
40
+ Classifier: Programming Language :: Python :: 3.11
41
+ Classifier: Programming Language :: Python :: 3.12
42
+ Classifier: Programming Language :: Python :: 3.13
43
+ Classifier: Topic :: Communications
44
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
45
+ Requires-Python: >=3.10
46
+ Requires-Dist: websockets>=12.0
47
+ Provides-Extra: crypto
48
+ Requires-Dist: pynacl>=1.5.0; extra == 'crypto'
49
+ Description-Content-Type: text/markdown
50
+
51
+ # simplepush
52
+
53
+ Python client for [Simplepush](https://simplepu.sh).
54
+
55
+ Send tasks, stream events over WebSocket, and decrypt end-to-end-encrypted
56
+ payloads from Python.
57
+
58
+ ## Install
59
+
60
+ ```bash
61
+ pip install simplepush # HTTP + WebSocket only
62
+ pip install 'simplepush[crypto]' # adds end-to-end encryption support
63
+ ```
64
+
65
+ Requires Python 3.10+.
66
+
67
+ ## Sending a task
68
+
69
+ ```python
70
+ from simplepush import Client, TextInput, ChoiceInput
71
+
72
+ client = Client(api_token="USER_API_TOKEN")
73
+
74
+ group = client.send_task(
75
+ topic="mytopic",
76
+ title="Approve deploy?",
77
+ inputs=[
78
+ ChoiceInput(description="Deploy v1.2.3?", options=["yes", "no"], required=True),
79
+ TextInput(description="Note (optional)"),
80
+ ],
81
+ )
82
+ task = group.sole # single-recipient topic; iterate the group for many
83
+ ```
84
+
85
+ > **Ids are type-prefixed strings.** `task_id`, `subtask_id`, input/reply/file
86
+ > ids and the like come back type-tagged — `tsk_…`, `sub_…`, `inp_…`, `rpl_…`
87
+ > (a reply), `rfl_…` (a reply's file) — not bare UUIDs.
88
+
89
+ By default every recipient gets their **own independent task instance** (one
90
+ recipient's answers never touch another's task), returned as a `TaskGroup` of
91
+ per-recipient `Task` handles:
92
+
93
+ ```python
94
+ group = client.send_task(topic="mytopic", content="check in")
95
+ for task in group: # or group.instances
96
+ print(task.task_id, task.recipient.public_id, task.recipient.name)
97
+
98
+ subs = group.append(content="follow-up") # a subtask on every member's chain
99
+ group.append(content="just you", instances=[group.instances[0]]) # or a subset
100
+
101
+ task = client.send_task(topic="mytopic", content="hi", shared=True) # shared mode: ONE task everyone answers together
102
+ ```
103
+
104
+ Both send methods take exactly one keyword-only target: `topic=` on any client,
105
+ or `member=` / `broadcast=` on an `OrgClient`. Omit the target on a personal
106
+ `Client` to send to your own devices (a self-send, returned as a single `Task` /
107
+ `Notification`; encrypted under the account personal password when one is
108
+ configured).
109
+
110
+ Other send options: `auto_commit=False` has the recipient submit the whole
111
+ form at once (by default each filled input arrives as an intermediate
112
+ `InputEvent`, then the terminal `TaskCompleted` carries the full committed
113
+ set); `reply=ReplyMode.STICKY` (or `"one-shot"` / `"one-time-per-user"`) shows
114
+ recipients an in-thread reply composer (collect via `replies()`);
115
+ `content_format=ContentFormat.MARKDOWN` renders `content` as Markdown;
116
+ `critical=True` sends an iOS Critical Alert.
117
+
118
+ A task can have **subtasks** appended to its chain. A subtask inherits the
119
+ parent's recipients and encryption (no target, no password); its `inputs()` /
120
+ `replies()` are scoped to it, and stream off the same shared connection:
121
+
122
+ ```python
123
+ sub = task.append(title="One more thing", inputs=[TextInput()])
124
+ async for ev in sub.inputs():
125
+ if isinstance(ev, SubtaskCompleted):
126
+ print(ev.uploads)
127
+ ```
128
+
129
+ ## Inputs
130
+
131
+ Task inputs: `TextInput`, `ChoiceInput` (set `multi=True`, with optional
132
+ `min_selections`/`max_selections`), `ActionsInput` (styled buttons; the tapped
133
+ action's stable `key` comes back), `SliderInput` (`min`/`max`/`step`/`unit`),
134
+ `PhotoInput`, `VoiceRecordingInput`, `FileUploadInput`, `LocationInput`.
135
+
136
+ ```python
137
+ from simplepush import (
138
+ Client, Action, ActionStyle, ActionsInput, SliderInput, ChoiceInput, PhotoInput,
139
+ TaskCompleted, ActionUpload, SliderUpload, MultiChoiceUpload, PhotoUpload,
140
+ )
141
+
142
+ client = Client(api_token="USER_API_TOKEN")
143
+
144
+ incident = client.send_task(
145
+ topic="ops",
146
+ title="Incident 4711",
147
+ inputs=[
148
+ ActionsInput(actions=[
149
+ Action(key="ack", label="Acknowledge", style=ActionStyle.PRIMARY),
150
+ Action(key="escalate", label="Escalate", style=ActionStyle.DESTRUCTIVE),
151
+ ]),
152
+ SliderInput(min=0, max=10, step=1, unit="sev"),
153
+ ChoiceInput(options=["db", "api", "infra"], multi=True, required=False),
154
+ PhotoInput(required=False),
155
+ ],
156
+ )
157
+ async for ev in incident.inputs():
158
+ if not isinstance(ev.item, TaskCompleted):
159
+ continue
160
+ for u in ev.item.uploads:
161
+ match u:
162
+ case ActionUpload(key=key):
163
+ print(ev.recipient.name, "pressed", key)
164
+ case SliderUpload(value=value):
165
+ print("severity", value)
166
+ case MultiChoiceUpload(values=values):
167
+ print("areas", values)
168
+ case PhotoUpload() as photo:
169
+ await photo.save("./incident-4711")
170
+ ```
171
+
172
+ Streams accept `timeout=` (seconds of silence before iteration stops; on a
173
+ group stream the timeout is group-wide) and `replay=True` (replay the buffered
174
+ backlog since the send before going live).
175
+
176
+ **File downloads.** The binary upload objects (photo/voice/file uploads, a
177
+ reply's `photo`/`file`/`audio`, and submission files) are download handles
178
+ bound to the client that yielded them: `await x.read()` returns the bytes
179
+ (checksum-verified, decrypted on encrypted chains), `await x.save(path)`
180
+ writes to disk (a directory uses the file's own name), and
181
+ `await x.download_url()` returns the raw short-lived presigned URL plus its
182
+ expiry. Failures raise `DownloadError`.
183
+
184
+ ## Sending a notification
185
+
186
+ A notification is a lighter sibling of a task: it carries a single input
187
+ (choice/text/actions only) and has no replies or subtasks.
188
+
189
+ Like `send_task`, the default is **independent** — every recipient gets their
190
+ own notification instance, returned as a `NotificationGroup`:
191
+
192
+ ```python
193
+ from simplepush import Client, NotificationChoiceInput, NotificationActionInput, Action, ActionStyle
194
+
195
+ client = Client(api_token="USER_API_TOKEN")
196
+
197
+ group = client.send_notification(
198
+ topic="mytopic",
199
+ title="Build failed",
200
+ content="main @ a1b2c3 failed 3 tests",
201
+ input=NotificationChoiceInput(options=["ack", "mute"]),
202
+ )
203
+ note = group.sole # single-recipient topic; iterate the group for many
204
+
205
+ async for ev in note.inputs():
206
+ print(ev.reply) # NotificationTextReply / NotificationChoiceReply / NotificationActionReply
207
+
208
+ # Action buttons (approve/deny), like a task's ActionsInput — on an encrypted
209
+ # send both the `key` and the `label` are sealed, and so is the reported answer:
210
+ group = client.send_notification(
211
+ topic="mytopic",
212
+ title="Deploy v1.2.3?",
213
+ input=NotificationActionInput(actions=[
214
+ Action(key="approve", label="Approve"),
215
+ Action(key="deny", label="Deny", style=ActionStyle.DESTRUCTIVE),
216
+ ]),
217
+ )
218
+
219
+ # Shared mode: ONE notification all recipients see and answer together (the
220
+ # first answer completes it for everyone), returned as a plain `Notification`:
221
+ note = client.send_notification(topic="mytopic", content="heads up", shared=True)
222
+ ```
223
+
224
+ A notification can also carry ONE media item — `image=` (renders on iOS +
225
+ Android) or `audio=` (plays inline on iOS only) — as either an http(s) URL or
226
+ a local file path (uploaded, encrypted when the notification is).
227
+
228
+ ## Attachments
229
+
230
+ `files=` uploads local files alongside a task/subtask (encrypted when the send
231
+ is; each file is read fully into memory). A notification takes its single
232
+ media item the same way, or as a URL:
233
+
234
+ ```python
235
+ client.send_task(
236
+ topic="reports",
237
+ title="Q3 numbers",
238
+ content="Full report attached.",
239
+ files=["q3.pdf"],
240
+ )
241
+ client.send_notification(topic="alerts", title="Door cam", image="https://cam.example/last.jpg")
242
+ ```
243
+
244
+ ## Submissions
245
+
246
+ A **submission** is self-authored user content — a text body plus an optional
247
+ photo, file, audio clip, and location — pushed into a user's own stream with
248
+ no associated task; a task reply without the task. Submissions are *created*
249
+ by the app; the library *observes* them on the client's feed (both `Client`
250
+ and `OrgClient`):
251
+
252
+ ```python
253
+ async for sub in client.submissions(timeout=300):
254
+ # sub: Submission — body / photo / file / audio / location
255
+ if sub.photo:
256
+ await sub.photo.save("./inbox")
257
+ ```
258
+
259
+ `photo`/`file`/`audio` are download handles (`read()` / `save()` /
260
+ `download_url()`); `audio` carries `duration_seconds`. `location` is inline
261
+ decoded data (latitude, longitude, accuracy, altitude, heading, speed,
262
+ timestamp). `timeout=` stops iteration after that many seconds of silence.
263
+
264
+ Encrypted submissions are decrypted with your **personal password**
265
+ (not a topic password). Pass it in `passwords=` (a bare string), or per call:
266
+
267
+ ```python
268
+ client = Client(api_token="USER_API_TOKEN", passwords="your-personal-password")
269
+ # or: client.submissions(password="your-personal-password")
270
+ ```
271
+
272
+ ## Streaming events
273
+
274
+ ```python
275
+ import asyncio
276
+ from simplepush import Client
277
+
278
+ async def main():
279
+ client = Client(api_token="USER_API_TOKEN")
280
+ async for event in client.events():
281
+ print(event.event_type, event.data)
282
+
283
+ asyncio.run(main())
284
+ ```
285
+
286
+ Every stream on a client shares one WebSocket. Call `await client.aclose()` when
287
+ you are done collecting; sends on their own never open it.
288
+
289
+ ## End-to-end encryption
290
+
291
+ Pass `password=` to encrypt a send's body fields. The returned handle decrypts
292
+ the recipient's replies/inputs under the same password.
293
+
294
+ ```python
295
+ from simplepush import Client, ReplyMode
296
+
297
+ # Per-send password (`reply=` so there is a composer to collect from):
298
+ client = Client(api_token="USER_API_TOKEN")
299
+ group = client.send_task(topic="mytopic", title="Secret", content="🤫",
300
+ password="hunter2", reply=ReplyMode.STICKY)
301
+
302
+ # Or configure a topic's password on the client; sends to it omit `password=`,
303
+ # and a per-send password still overrides. The pair's topic must match the
304
+ # topic you send to — otherwise nothing matches and the send goes plaintext:
305
+ client = Client(api_token="USER_API_TOKEN", passwords=[("hunter2", "mytopic")])
306
+ client.send_task(topic="mytopic", content="🤫") # encrypted with "hunter2"
307
+ client.send_task(topic="mytopic", content="!", password="x") # overridden for this send
308
+
309
+ async for reply in group.sole.replies():
310
+ print(reply.body) # decrypted
311
+ ```
312
+
313
+ To decrypt the raw `events()` feed across many passwords, build a keyring from
314
+ the client's configured `(password, topic)` pairs (it also grows with every
315
+ send) and apply it per event:
316
+
317
+ ```python
318
+ from simplepush import try_decrypt_event_data
319
+
320
+ client = Client(api_token="USER_API_TOKEN", passwords=[("hunter2", "mytopic"), ("other", "alerts")])
321
+ ring = client.keyring()
322
+ async for event in client.events():
323
+ data = try_decrypt_event_data(event, ring) # decrypted dict, or None if no key matches
324
+ ```
325
+
326
+ ## Organizations
327
+
328
+ `OrgClient` authenticates with the org `api_key` and addresses sends with
329
+ exactly one target: `topic=`, `member=` (by member name), or `broadcast=True`.
330
+ Encryption is automatic: pass the org's master key(s) (from your org's
331
+ encryption vault; the library can't derive them) and every send is encrypted
332
+ under the current key — there are no per-send passwords. Without keys, sends
333
+ go out in the clear and org ciphertext is passed through undecrypted.
334
+
335
+ ```python
336
+ from simplepush import OrgClient, ChoiceInput
337
+
338
+ org = OrgClient(
339
+ api_key="ORG_API_KEY",
340
+ master_key=MASTER_KEY, # 32 bytes (raw or base64)
341
+ master_key_version=3, # or several: master_keys={3: key3, 2: key2}
342
+ )
343
+
344
+ group = org.send_task(
345
+ broadcast=True,
346
+ title="All hands?",
347
+ inputs=[ChoiceInput(options=["yes", "no"])],
348
+ )
349
+ async for ev in group.inputs():
350
+ print(ev.recipient.name, ev.item) # recipient = the org member
351
+ ```
352
+
353
+ Everything else works as on a personal `Client`: independent-mode groups (the
354
+ member name rides on each instance's `recipient`), subtasks, streams,
355
+ submissions, downloads.
356
+
357
+ ## License
358
+
359
+ MIT