simplepush 3.3.0__tar.gz → 3.5.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.
- {simplepush-3.3.0 → simplepush-3.5.0}/PKG-INFO +4 -3
- {simplepush-3.3.0 → simplepush-3.5.0}/README.md +3 -2
- {simplepush-3.3.0 → simplepush-3.5.0}/pyproject.toml +1 -1
- {simplepush-3.3.0 → simplepush-3.5.0}/src/simplepush/api.py +13 -15
- {simplepush-3.3.0 → simplepush-3.5.0}/src/simplepush/decrypt.py +2 -1
- simplepush-3.3.0/.worktrees/pg-resilience/README.md +0 -309
- simplepush-3.3.0/.worktrees/pg-resilience/pyproject.toml +0 -75
- simplepush-3.3.0/LICENSE +0 -21
- {simplepush-3.3.0 → simplepush-3.5.0}/.gitignore +0 -0
- {simplepush-3.3.0/.worktrees/pg-resilience → simplepush-3.5.0}/LICENSE +0 -0
- {simplepush-3.3.0 → simplepush-3.5.0}/src/simplepush/__init__.py +0 -0
- {simplepush-3.3.0 → simplepush-3.5.0}/src/simplepush/_extras.py +0 -0
- {simplepush-3.3.0 → simplepush-3.5.0}/src/simplepush/client.py +0 -0
- {simplepush-3.3.0 → simplepush-3.5.0}/src/simplepush/crypto.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: simplepush
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.5.0
|
|
4
4
|
Summary: Python client for Simplepush (tasks, notifications, events, end-to-end encryption).
|
|
5
5
|
Project-URL: Homepage, https://simplepu.sh
|
|
6
6
|
Project-URL: Documentation, https://simplepu.sh/guide/python-sdk
|
|
@@ -112,8 +112,9 @@ form at once (by default each filled input arrives as an intermediate
|
|
|
112
112
|
`InputEvent`, then the terminal `TaskCompleted` carries the full committed
|
|
113
113
|
set); `reply=ReplyMode.STICKY` (or `"one-shot"` / `"one-time-per-user"`) shows
|
|
114
114
|
recipients an in-thread reply composer (collect via `replies()`);
|
|
115
|
-
`content_format=ContentFormat.MARKDOWN` renders `content` as
|
|
116
|
-
`critical=True` sends an iOS
|
|
115
|
+
`content_format=ContentFormat.MARKDOWN` renders a task's `content` as
|
|
116
|
+
Markdown (notifications are always plain); `critical=True` sends an iOS
|
|
117
|
+
Critical Alert.
|
|
117
118
|
|
|
118
119
|
A task can have **subtasks** appended to its chain. A subtask inherits the
|
|
119
120
|
parent's recipients and encryption (no target, no password); its `inputs()` /
|
|
@@ -62,8 +62,9 @@ form at once (by default each filled input arrives as an intermediate
|
|
|
62
62
|
`InputEvent`, then the terminal `TaskCompleted` carries the full committed
|
|
63
63
|
set); `reply=ReplyMode.STICKY` (or `"one-shot"` / `"one-time-per-user"`) shows
|
|
64
64
|
recipients an in-thread reply composer (collect via `replies()`);
|
|
65
|
-
`content_format=ContentFormat.MARKDOWN` renders `content` as
|
|
66
|
-
`critical=True` sends an iOS
|
|
65
|
+
`content_format=ContentFormat.MARKDOWN` renders a task's `content` as
|
|
66
|
+
Markdown (notifications are always plain); `critical=True` sends an iOS
|
|
67
|
+
Critical Alert.
|
|
67
68
|
|
|
68
69
|
A task can have **subtasks** appended to its chain. A subtask inherits the
|
|
69
70
|
parent's recipients and encryption (no target, no password); its `inputs()` /
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "simplepush"
|
|
7
|
-
version = "3.
|
|
7
|
+
version = "3.5.0"
|
|
8
8
|
description = "Python client for Simplepush (tasks, notifications, events, end-to-end encryption)."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = { file = "LICENSE" }
|
|
@@ -372,9 +372,10 @@ class CancelReason(str, Enum):
|
|
|
372
372
|
|
|
373
373
|
|
|
374
374
|
class ContentFormat(str, Enum):
|
|
375
|
-
"""How recipients render a task
|
|
376
|
-
`content_format=` argument to
|
|
377
|
-
titles are always plain.
|
|
375
|
+
"""How recipients render a task or subtask `content` body (the
|
|
376
|
+
`content_format=` argument to `send_task` / `append`). Governs `content`
|
|
377
|
+
only; titles are always plain. Notifications have no format marker: a
|
|
378
|
+
push always shows its body as plain text. The marker is sent as plaintext (never
|
|
378
379
|
encrypted). Members are `str`, so they serialize directly and compare
|
|
379
380
|
equal to their wire value (e.g. ``ContentFormat.MARKDOWN == "markdown"``).
|
|
380
381
|
"""
|
|
@@ -590,7 +591,7 @@ class _BaseClient:
|
|
|
590
591
|
inputs: list[InputType] | None = None,
|
|
591
592
|
links: list[str] | None = None,
|
|
592
593
|
files: "list[str | os.PathLike] | None" = None,
|
|
593
|
-
auto_commit: bool =
|
|
594
|
+
auto_commit: bool = False,
|
|
594
595
|
password: str | None = None,
|
|
595
596
|
tag: str | None = None,
|
|
596
597
|
critical: bool = False,
|
|
@@ -630,7 +631,8 @@ class _BaseClient:
|
|
|
630
631
|
Each file is read fully into memory, so this is unsuited to
|
|
631
632
|
very large files. Uploaded after the task is created; an
|
|
632
633
|
upload that fails is marked failed without failing the send.
|
|
633
|
-
auto_commit:
|
|
634
|
+
auto_commit: Default False: the task renders as a form with one
|
|
635
|
+
Submit for all inputs. True commits each input as it is filled.
|
|
634
636
|
password: Optional password to encrypt body fields with. Requires a
|
|
635
637
|
topic (used as the salt for key derivation). Falls back to
|
|
636
638
|
the client's default `password` when omitted. Not accepted
|
|
@@ -684,7 +686,6 @@ class _BaseClient:
|
|
|
684
686
|
password: str | None = None,
|
|
685
687
|
tag: str | None = None,
|
|
686
688
|
critical: bool = False,
|
|
687
|
-
content_format: ContentFormat | Literal["plain", "markdown"] | None = None,
|
|
688
689
|
shared: bool = False,
|
|
689
690
|
) -> "Notification | NotificationGroup":
|
|
690
691
|
"""Send a notification and return a handle to its event stream.
|
|
@@ -751,14 +752,13 @@ class _BaseClient:
|
|
|
751
752
|
title=title, content=content, input=input,
|
|
752
753
|
image=image, audio=audio,
|
|
753
754
|
password=password if password is not None else self._send_password(topic),
|
|
754
|
-
tag=tag, critical=critical,
|
|
755
|
-
content_format=content_format, shared=shared,
|
|
755
|
+
tag=tag, critical=critical, shared=shared,
|
|
756
756
|
)
|
|
757
757
|
|
|
758
758
|
def _create_task(self, *, topic=None, member=None, broadcast=False,
|
|
759
759
|
title=None, content=None, inputs=None, links=None,
|
|
760
760
|
files=None,
|
|
761
|
-
auto_commit=
|
|
761
|
+
auto_commit=False, password=None, tag=None, critical=False,
|
|
762
762
|
reply=None, content_format=None, shared=False,
|
|
763
763
|
expires_at=None) -> "Task | TaskGroup":
|
|
764
764
|
if not content and not inputs:
|
|
@@ -966,7 +966,7 @@ class _BaseClient:
|
|
|
966
966
|
|
|
967
967
|
def _create_notification(self, *, topic=None, member=None, broadcast=False,
|
|
968
968
|
title=None, content=None, input=None, image=None, audio=None,
|
|
969
|
-
password=None, tag=None, critical=False,
|
|
969
|
+
password=None, tag=None, critical=False,
|
|
970
970
|
shared=False) -> "Notification | NotificationGroup":
|
|
971
971
|
if not content and input is None:
|
|
972
972
|
raise ValueError("Either content or an input must be provided")
|
|
@@ -1087,8 +1087,6 @@ class _BaseClient:
|
|
|
1087
1087
|
payload["actionInput"] = {"actions": action_defs}
|
|
1088
1088
|
if critical:
|
|
1089
1089
|
payload["critical"] = critical
|
|
1090
|
-
if content_format is not None:
|
|
1091
|
-
payload["contentFormat"] = content_format.value if isinstance(content_format, ContentFormat) else content_format
|
|
1092
1090
|
if encryption_dict is not None:
|
|
1093
1091
|
payload["encryption"] = encryption_dict
|
|
1094
1092
|
if shared:
|
|
@@ -1216,7 +1214,7 @@ class _BaseClient:
|
|
|
1216
1214
|
|
|
1217
1215
|
def _build_subtask_data(self, send_key, *, title=None, content=None, inputs=None,
|
|
1218
1216
|
links=None, files=None,
|
|
1219
|
-
auto_commit=
|
|
1217
|
+
auto_commit=False, critical=False,
|
|
1220
1218
|
reply=None, content_format=None) -> "tuple[dict, list]":
|
|
1221
1219
|
"""Build the (encrypted) `data` dict of a subtask append plus the
|
|
1222
1220
|
prepared local attachments awaiting upload — shared by the single-task
|
|
@@ -1321,7 +1319,7 @@ class _BaseClient:
|
|
|
1321
1319
|
|
|
1322
1320
|
def _append_subtask(self, task, *, title=None, content=None, inputs=None,
|
|
1323
1321
|
links=None, files=None,
|
|
1324
|
-
auto_commit=
|
|
1322
|
+
auto_commit=False, critical=False,
|
|
1325
1323
|
reply=None, content_format=None) -> Subtask:
|
|
1326
1324
|
if not task.append_token:
|
|
1327
1325
|
raise RuntimeError("this task has no append token; cannot append a subtask")
|
|
@@ -1358,7 +1356,7 @@ class _BaseClient:
|
|
|
1358
1356
|
|
|
1359
1357
|
def _append_subtasks_to_group(self, group, *, instances=None, title=None,
|
|
1360
1358
|
content=None, inputs=None, links=None, files=None,
|
|
1361
|
-
auto_commit=
|
|
1359
|
+
auto_commit=False, critical=False,
|
|
1362
1360
|
reply=None, content_format=None) -> "list[Subtask]":
|
|
1363
1361
|
"""Append one subtask per member instance to a task group's chains,
|
|
1364
1362
|
atomically, via the group append token. `instances` (task ids) restricts
|
|
@@ -188,12 +188,13 @@ def decrypt_task_payload(value: Any, keyring) -> DecryptedWire:
|
|
|
188
188
|
|
|
189
189
|
|
|
190
190
|
def decrypt_task_summary(value: Any, keyring) -> DecryptedWire:
|
|
191
|
-
"""A task index / group roster row: ``title``
|
|
191
|
+
"""A task index / group roster row: ``title`` and ``tag`` are its sealed fields."""
|
|
192
192
|
st = _State()
|
|
193
193
|
out = copy.deepcopy(value)
|
|
194
194
|
if isinstance(out, dict):
|
|
195
195
|
marker = _marker_of(out.pop("encryption", None))
|
|
196
196
|
_dec_field(out, "title", marker, keyring, st)
|
|
197
|
+
_dec_field(out, "tag", marker, keyring, st)
|
|
197
198
|
return DecryptedWire(out, st.undecryptable)
|
|
198
199
|
|
|
199
200
|
|
|
@@ -1,309 +0,0 @@
|
|
|
1
|
-
# simplepush
|
|
2
|
-
|
|
3
|
-
Python client for [Simplepush](https://simplepu.sh).
|
|
4
|
-
|
|
5
|
-
Send tasks, stream events over WebSocket, and decrypt end-to-end-encrypted
|
|
6
|
-
payloads from Python.
|
|
7
|
-
|
|
8
|
-
## Install
|
|
9
|
-
|
|
10
|
-
```bash
|
|
11
|
-
pip install simplepush # HTTP + WebSocket only
|
|
12
|
-
pip install 'simplepush[crypto]' # adds end-to-end encryption support
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
Requires Python 3.10+.
|
|
16
|
-
|
|
17
|
-
## Sending a task
|
|
18
|
-
|
|
19
|
-
```python
|
|
20
|
-
from simplepush import Client, TextInput, ChoiceInput
|
|
21
|
-
|
|
22
|
-
client = Client(api_token="USER_API_TOKEN")
|
|
23
|
-
|
|
24
|
-
group = client.send_task(
|
|
25
|
-
topic="mytopic",
|
|
26
|
-
title="Approve deploy?",
|
|
27
|
-
inputs=[
|
|
28
|
-
ChoiceInput(description="Deploy v1.2.3?", options=["yes", "no"], required=True),
|
|
29
|
-
TextInput(description="Note (optional)"),
|
|
30
|
-
],
|
|
31
|
-
)
|
|
32
|
-
task = group.sole # single-recipient topic; iterate the group for many
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
> **Ids are type-prefixed strings.** `task_id`, `subtask_id`, input/reply/file
|
|
36
|
-
> ids and the like come back type-tagged — `tsk_…`, `sub_…`, `inp_…`, `rpl_…`
|
|
37
|
-
> (a reply), `rfl_…` (a reply's file) — not bare UUIDs.
|
|
38
|
-
|
|
39
|
-
By default every recipient gets their **own independent task instance** (one
|
|
40
|
-
recipient's answers never touch another's task), returned as a `TaskGroup` of
|
|
41
|
-
per-recipient `Task` handles:
|
|
42
|
-
|
|
43
|
-
```python
|
|
44
|
-
group = client.send_task(topic="mytopic", content="check in")
|
|
45
|
-
for task in group: # or group.instances
|
|
46
|
-
print(task.task_id, task.recipient.public_id, task.recipient.name)
|
|
47
|
-
|
|
48
|
-
subs = group.append(content="follow-up") # a subtask on every member's chain
|
|
49
|
-
group.append(content="just you", instances=[group.instances[0]]) # or a subset
|
|
50
|
-
|
|
51
|
-
task = client.send_task(topic="mytopic", content="hi", shared=True) # shared mode: ONE task everyone answers together
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
Both send methods take exactly one keyword-only target: `topic=` on any client,
|
|
55
|
-
or `member=` / `broadcast=` on an `OrgClient`. Omit the target on a personal
|
|
56
|
-
`Client` to send to your own devices (a self-send, returned as a single `Task` /
|
|
57
|
-
`Notification`; encrypted under the account personal password when one is
|
|
58
|
-
configured).
|
|
59
|
-
|
|
60
|
-
Other send options: `auto_commit=False` has the recipient submit the whole
|
|
61
|
-
form at once (by default each filled input arrives as an intermediate
|
|
62
|
-
`InputEvent`, then the terminal `TaskCompleted` carries the full committed
|
|
63
|
-
set); `reply=ReplyMode.STICKY` (or `"one-shot"` / `"one-time-per-user"`) shows
|
|
64
|
-
recipients an in-thread reply composer (collect via `replies()`);
|
|
65
|
-
`content_format=ContentFormat.MARKDOWN` renders `content` as Markdown;
|
|
66
|
-
`critical=True` sends an iOS Critical Alert.
|
|
67
|
-
|
|
68
|
-
A task can have **subtasks** appended to its chain. A subtask inherits the
|
|
69
|
-
parent's recipients and encryption (no target, no password); its `inputs()` /
|
|
70
|
-
`replies()` are scoped to it, and stream off the same shared connection:
|
|
71
|
-
|
|
72
|
-
```python
|
|
73
|
-
sub = task.append(title="One more thing", inputs=[TextInput()])
|
|
74
|
-
async for ev in sub.inputs():
|
|
75
|
-
if isinstance(ev, SubtaskCompleted):
|
|
76
|
-
print(ev.uploads)
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
## Inputs
|
|
80
|
-
|
|
81
|
-
Task inputs: `TextInput`, `ChoiceInput` (set `multi=True`, with optional
|
|
82
|
-
`min_selections`/`max_selections`), `ActionsInput` (styled buttons; the tapped
|
|
83
|
-
action's stable `key` comes back), `SliderInput` (`min`/`max`/`step`/`unit`),
|
|
84
|
-
`PhotoInput`, `VoiceRecordingInput`, `FileUploadInput`, `LocationInput`.
|
|
85
|
-
|
|
86
|
-
```python
|
|
87
|
-
from simplepush import (
|
|
88
|
-
Client, Action, ActionStyle, ActionsInput, SliderInput, ChoiceInput, PhotoInput,
|
|
89
|
-
TaskCompleted, ActionUpload, SliderUpload, MultiChoiceUpload, PhotoUpload,
|
|
90
|
-
)
|
|
91
|
-
|
|
92
|
-
client = Client(api_token="USER_API_TOKEN")
|
|
93
|
-
|
|
94
|
-
incident = client.send_task(
|
|
95
|
-
topic="ops",
|
|
96
|
-
title="Incident 4711",
|
|
97
|
-
inputs=[
|
|
98
|
-
ActionsInput(actions=[
|
|
99
|
-
Action(key="ack", label="Acknowledge", style=ActionStyle.PRIMARY),
|
|
100
|
-
Action(key="escalate", label="Escalate", style=ActionStyle.DESTRUCTIVE),
|
|
101
|
-
]),
|
|
102
|
-
SliderInput(min=0, max=10, step=1, unit="sev"),
|
|
103
|
-
ChoiceInput(options=["db", "api", "infra"], multi=True, required=False),
|
|
104
|
-
PhotoInput(required=False),
|
|
105
|
-
],
|
|
106
|
-
)
|
|
107
|
-
async for ev in incident.inputs():
|
|
108
|
-
if not isinstance(ev.item, TaskCompleted):
|
|
109
|
-
continue
|
|
110
|
-
for u in ev.item.uploads:
|
|
111
|
-
match u:
|
|
112
|
-
case ActionUpload(key=key):
|
|
113
|
-
print(ev.recipient.name, "pressed", key)
|
|
114
|
-
case SliderUpload(value=value):
|
|
115
|
-
print("severity", value)
|
|
116
|
-
case MultiChoiceUpload(values=values):
|
|
117
|
-
print("areas", values)
|
|
118
|
-
case PhotoUpload() as photo:
|
|
119
|
-
await photo.save("./incident-4711")
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
Streams accept `timeout=` (seconds of silence before iteration stops; on a
|
|
123
|
-
group stream the timeout is group-wide) and `replay=True` (replay the buffered
|
|
124
|
-
backlog since the send before going live).
|
|
125
|
-
|
|
126
|
-
**File downloads.** The binary upload objects (photo/voice/file uploads, a
|
|
127
|
-
reply's `photo`/`file`/`audio`, and submission files) are download handles
|
|
128
|
-
bound to the client that yielded them: `await x.read()` returns the bytes
|
|
129
|
-
(checksum-verified, decrypted on encrypted chains), `await x.save(path)`
|
|
130
|
-
writes to disk (a directory uses the file's own name), and
|
|
131
|
-
`await x.download_url()` returns the raw short-lived presigned URL plus its
|
|
132
|
-
expiry. Failures raise `DownloadError`.
|
|
133
|
-
|
|
134
|
-
## Sending a notification
|
|
135
|
-
|
|
136
|
-
A notification is a lighter sibling of a task: it carries a single input
|
|
137
|
-
(choice/text/actions only) and has no replies or subtasks.
|
|
138
|
-
|
|
139
|
-
Like `send_task`, the default is **independent** — every recipient gets their
|
|
140
|
-
own notification instance, returned as a `NotificationGroup`:
|
|
141
|
-
|
|
142
|
-
```python
|
|
143
|
-
from simplepush import Client, NotificationChoiceInput, NotificationActionInput, Action, ActionStyle
|
|
144
|
-
|
|
145
|
-
client = Client(api_token="USER_API_TOKEN")
|
|
146
|
-
|
|
147
|
-
group = client.send_notification(
|
|
148
|
-
topic="mytopic",
|
|
149
|
-
title="Build failed",
|
|
150
|
-
content="main @ a1b2c3 failed 3 tests",
|
|
151
|
-
input=NotificationChoiceInput(options=["ack", "mute"]),
|
|
152
|
-
)
|
|
153
|
-
note = group.sole # single-recipient topic; iterate the group for many
|
|
154
|
-
|
|
155
|
-
async for ev in note.inputs():
|
|
156
|
-
print(ev.reply) # NotificationTextReply / NotificationChoiceReply / NotificationActionReply
|
|
157
|
-
|
|
158
|
-
# Action buttons (approve/deny), like a task's ActionsInput — on an encrypted
|
|
159
|
-
# send both the `key` and the `label` are sealed, and so is the reported answer:
|
|
160
|
-
group = client.send_notification(
|
|
161
|
-
topic="mytopic",
|
|
162
|
-
title="Deploy v1.2.3?",
|
|
163
|
-
input=NotificationActionInput(actions=[
|
|
164
|
-
Action(key="approve", label="Approve"),
|
|
165
|
-
Action(key="deny", label="Deny", style=ActionStyle.DESTRUCTIVE),
|
|
166
|
-
]),
|
|
167
|
-
)
|
|
168
|
-
|
|
169
|
-
# Shared mode: ONE notification all recipients see and answer together (the
|
|
170
|
-
# first answer completes it for everyone), returned as a plain `Notification`:
|
|
171
|
-
note = client.send_notification(topic="mytopic", content="heads up", shared=True)
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
A notification can also carry ONE media item — `image=` (renders on iOS +
|
|
175
|
-
Android) or `audio=` (plays inline on iOS only) — as either an http(s) URL or
|
|
176
|
-
a local file path (uploaded, encrypted when the notification is).
|
|
177
|
-
|
|
178
|
-
## Attachments
|
|
179
|
-
|
|
180
|
-
`files=` uploads local files alongside a task/subtask (encrypted when the send
|
|
181
|
-
is; each file is read fully into memory). A notification takes its single
|
|
182
|
-
media item the same way, or as a URL:
|
|
183
|
-
|
|
184
|
-
```python
|
|
185
|
-
client.send_task(
|
|
186
|
-
topic="reports",
|
|
187
|
-
title="Q3 numbers",
|
|
188
|
-
content="Full report attached.",
|
|
189
|
-
files=["q3.pdf"],
|
|
190
|
-
)
|
|
191
|
-
client.send_notification(topic="alerts", title="Door cam", image="https://cam.example/last.jpg")
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
## Submissions
|
|
195
|
-
|
|
196
|
-
A **submission** is self-authored user content — a text body plus an optional
|
|
197
|
-
photo, file, audio clip, and location — pushed into a user's own stream with
|
|
198
|
-
no associated task; a task reply without the task. Submissions are *created*
|
|
199
|
-
by the app; the library *observes* them on the client's feed (both `Client`
|
|
200
|
-
and `OrgClient`):
|
|
201
|
-
|
|
202
|
-
```python
|
|
203
|
-
async for sub in client.submissions(timeout=300):
|
|
204
|
-
# sub: Submission — body / photo / file / audio / location
|
|
205
|
-
if sub.photo:
|
|
206
|
-
await sub.photo.save("./inbox")
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
`photo`/`file`/`audio` are download handles (`read()` / `save()` /
|
|
210
|
-
`download_url()`); `audio` carries `duration_seconds`. `location` is inline
|
|
211
|
-
decoded data (latitude, longitude, accuracy, altitude, heading, speed,
|
|
212
|
-
timestamp). `timeout=` stops iteration after that many seconds of silence.
|
|
213
|
-
|
|
214
|
-
Encrypted submissions are decrypted with your **personal password**
|
|
215
|
-
(not a topic password). Pass it in `passwords=` (a bare string), or per call:
|
|
216
|
-
|
|
217
|
-
```python
|
|
218
|
-
client = Client(api_token="USER_API_TOKEN", passwords="your-personal-password")
|
|
219
|
-
# or: client.submissions(password="your-personal-password")
|
|
220
|
-
```
|
|
221
|
-
|
|
222
|
-
## Streaming events
|
|
223
|
-
|
|
224
|
-
```python
|
|
225
|
-
import asyncio
|
|
226
|
-
from simplepush import Client
|
|
227
|
-
|
|
228
|
-
async def main():
|
|
229
|
-
client = Client(api_token="USER_API_TOKEN")
|
|
230
|
-
async for event in client.events():
|
|
231
|
-
print(event.event_type, event.data)
|
|
232
|
-
|
|
233
|
-
asyncio.run(main())
|
|
234
|
-
```
|
|
235
|
-
|
|
236
|
-
Every stream on a client shares one WebSocket. Call `await client.aclose()` when
|
|
237
|
-
you are done collecting; sends on their own never open it.
|
|
238
|
-
|
|
239
|
-
## End-to-end encryption
|
|
240
|
-
|
|
241
|
-
Pass `password=` to encrypt a send's body fields. The returned handle decrypts
|
|
242
|
-
the recipient's replies/inputs under the same password.
|
|
243
|
-
|
|
244
|
-
```python
|
|
245
|
-
from simplepush import Client, ReplyMode
|
|
246
|
-
|
|
247
|
-
# Per-send password (`reply=` so there is a composer to collect from):
|
|
248
|
-
client = Client(api_token="USER_API_TOKEN")
|
|
249
|
-
group = client.send_task(topic="mytopic", title="Secret", content="🤫",
|
|
250
|
-
password="hunter2", reply=ReplyMode.STICKY)
|
|
251
|
-
|
|
252
|
-
# Or configure a topic's password on the client; sends to it omit `password=`,
|
|
253
|
-
# and a per-send password still overrides. The pair's topic must match the
|
|
254
|
-
# topic you send to — otherwise nothing matches and the send goes plaintext:
|
|
255
|
-
client = Client(api_token="USER_API_TOKEN", passwords=[("hunter2", "mytopic")])
|
|
256
|
-
client.send_task(topic="mytopic", content="🤫") # encrypted with "hunter2"
|
|
257
|
-
client.send_task(topic="mytopic", content="!", password="x") # overridden for this send
|
|
258
|
-
|
|
259
|
-
async for reply in group.sole.replies():
|
|
260
|
-
print(reply.body) # decrypted
|
|
261
|
-
```
|
|
262
|
-
|
|
263
|
-
To decrypt the raw `events()` feed across many passwords, build a keyring from
|
|
264
|
-
the client's configured `(password, topic)` pairs (it also grows with every
|
|
265
|
-
send) and apply it per event:
|
|
266
|
-
|
|
267
|
-
```python
|
|
268
|
-
from simplepush import try_decrypt_event_data
|
|
269
|
-
|
|
270
|
-
client = Client(api_token="USER_API_TOKEN", passwords=[("hunter2", "mytopic"), ("other", "alerts")])
|
|
271
|
-
ring = client.keyring()
|
|
272
|
-
async for event in client.events():
|
|
273
|
-
data = try_decrypt_event_data(event, ring) # decrypted dict, or None if no key matches
|
|
274
|
-
```
|
|
275
|
-
|
|
276
|
-
## Organizations
|
|
277
|
-
|
|
278
|
-
`OrgClient` authenticates with the org `api_key` and addresses sends with
|
|
279
|
-
exactly one target: `topic=`, `member=` (by member name), or `broadcast=True`.
|
|
280
|
-
Encryption is automatic: pass the org's master key(s) (from your org's
|
|
281
|
-
encryption vault; the library can't derive them) and every send is encrypted
|
|
282
|
-
under the current key — there are no per-send passwords. Without keys, sends
|
|
283
|
-
go out in the clear and org ciphertext is passed through undecrypted.
|
|
284
|
-
|
|
285
|
-
```python
|
|
286
|
-
from simplepush import OrgClient, ChoiceInput
|
|
287
|
-
|
|
288
|
-
org = OrgClient(
|
|
289
|
-
api_key="ORG_API_KEY",
|
|
290
|
-
master_key=MASTER_KEY, # 32 bytes (raw or base64)
|
|
291
|
-
master_key_version=3, # or several: master_keys={3: key3, 2: key2}
|
|
292
|
-
)
|
|
293
|
-
|
|
294
|
-
group = org.send_task(
|
|
295
|
-
broadcast=True,
|
|
296
|
-
title="All hands?",
|
|
297
|
-
inputs=[ChoiceInput(options=["yes", "no"])],
|
|
298
|
-
)
|
|
299
|
-
async for ev in group.inputs():
|
|
300
|
-
print(ev.recipient.name, ev.item) # recipient = the org member
|
|
301
|
-
```
|
|
302
|
-
|
|
303
|
-
Everything else works as on a personal `Client`: independent-mode groups (the
|
|
304
|
-
member name rides on each instance's `recipient`), subtasks, streams,
|
|
305
|
-
submissions, downloads.
|
|
306
|
-
|
|
307
|
-
## License
|
|
308
|
-
|
|
309
|
-
MIT
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
[build-system]
|
|
2
|
-
requires = ["hatchling"]
|
|
3
|
-
build-backend = "hatchling.build"
|
|
4
|
-
|
|
5
|
-
[project]
|
|
6
|
-
name = "simplepush"
|
|
7
|
-
version = "3.1.0"
|
|
8
|
-
description = "Python client for Simplepush (tasks, notifications, events, end-to-end encryption)."
|
|
9
|
-
readme = "README.md"
|
|
10
|
-
license = { file = "LICENSE" }
|
|
11
|
-
requires-python = ">=3.10"
|
|
12
|
-
authors = [{ name = "Timm Schaeuble", email = "contact@simplepush.io" }]
|
|
13
|
-
keywords = [
|
|
14
|
-
"simplepush",
|
|
15
|
-
"push",
|
|
16
|
-
"notifications",
|
|
17
|
-
"actionable-notifications",
|
|
18
|
-
"websocket",
|
|
19
|
-
"events",
|
|
20
|
-
"tasks",
|
|
21
|
-
"workflow",
|
|
22
|
-
"automation",
|
|
23
|
-
"low-code",
|
|
24
|
-
"no-code",
|
|
25
|
-
"forms",
|
|
26
|
-
"data-collection",
|
|
27
|
-
"human-in-the-loop",
|
|
28
|
-
"approvals",
|
|
29
|
-
"mobile",
|
|
30
|
-
"end-to-end-encryption",
|
|
31
|
-
]
|
|
32
|
-
classifiers = [
|
|
33
|
-
"Development Status :: 5 - Production/Stable",
|
|
34
|
-
"Intended Audience :: Developers",
|
|
35
|
-
"License :: OSI Approved :: MIT License",
|
|
36
|
-
"Operating System :: OS Independent",
|
|
37
|
-
"Programming Language :: Python :: 3",
|
|
38
|
-
"Programming Language :: Python :: 3 :: Only",
|
|
39
|
-
"Programming Language :: Python :: 3.10",
|
|
40
|
-
"Programming Language :: Python :: 3.11",
|
|
41
|
-
"Programming Language :: Python :: 3.12",
|
|
42
|
-
"Programming Language :: Python :: 3.13",
|
|
43
|
-
"Topic :: Communications",
|
|
44
|
-
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
45
|
-
]
|
|
46
|
-
|
|
47
|
-
# The HTTP path uses stdlib `urllib`. WebSocket events need the `websockets`
|
|
48
|
-
# package. The crypto extra pulls in libsodium (`pynacl`) for Argon2id and
|
|
49
|
-
# XChaCha20-Poly1305, matching the other clients' wire format; callers who only
|
|
50
|
-
# want event/HTTP can install without it.
|
|
51
|
-
dependencies = [
|
|
52
|
-
"websockets>=12.0",
|
|
53
|
-
]
|
|
54
|
-
|
|
55
|
-
[project.optional-dependencies]
|
|
56
|
-
crypto = [
|
|
57
|
-
"pynacl>=1.5.0",
|
|
58
|
-
]
|
|
59
|
-
|
|
60
|
-
[project.urls]
|
|
61
|
-
Homepage = "https://simplepu.sh"
|
|
62
|
-
Documentation = "https://simplepu.sh/guide/python-sdk"
|
|
63
|
-
Source = "https://github.com/simplepush/simplepush-python"
|
|
64
|
-
Issues = "https://github.com/simplepush/simplepush-python/issues"
|
|
65
|
-
|
|
66
|
-
[tool.hatch.build.targets.wheel]
|
|
67
|
-
packages = ["src/simplepush"]
|
|
68
|
-
|
|
69
|
-
[tool.hatch.build.targets.sdist]
|
|
70
|
-
include = [
|
|
71
|
-
"src/simplepush",
|
|
72
|
-
"README.md",
|
|
73
|
-
"LICENSE",
|
|
74
|
-
"pyproject.toml",
|
|
75
|
-
]
|
simplepush-3.3.0/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
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.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|