iskoldtbark 0.1.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,34 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ jobs:
8
+ pypi-publish:
9
+ name: Build and publish Python package
10
+ runs-on: ubuntu-latest
11
+ environment:
12
+ name: pypi
13
+ url: https://pypi.org/p/iskoldtbark
14
+ permissions:
15
+ id-token: write
16
+ contents: read
17
+
18
+ steps:
19
+ - name: Checkout repository
20
+ uses: actions/checkout@v4
21
+
22
+ - name: Set up Python
23
+ uses: actions/setup-python@v5
24
+ with:
25
+ python-version: "3.x"
26
+
27
+ - name: Install pypa/build
28
+ run: python -m pip install build --user
29
+
30
+ - name: Build a binary wheel and a source tarball
31
+ run: python -m build
32
+
33
+ - name: Publish package distributions to PyPI
34
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,12 @@
1
+ __pycache__/
2
+ *.pyc
3
+ *.pyo
4
+ venv/
5
+ .venv/
6
+ *.egg-info/
7
+ dist/
8
+ build/
9
+ .pytest_cache/
10
+ .mypy_cache/
11
+ *.dist-info/RECORD
12
+ CLAUDE.md
@@ -0,0 +1,175 @@
1
+ Metadata-Version: 2.4
2
+ Name: iskoldtbark
3
+ Version: 0.1.0
4
+ Summary: A secure, official-compliant Python client for the Bark push notification service.
5
+ Author-email: Developer <developer@example.com>
6
+ License: MIT
7
+ Classifier: License :: OSI Approved :: MIT License
8
+ Classifier: Operating System :: OS Independent
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Topic :: Communications
11
+ Requires-Python: >=3.8
12
+ Requires-Dist: cryptography>=41.0.0
13
+ Requires-Dist: requests>=2.25.0
14
+ Provides-Extra: dev
15
+ Requires-Dist: black>=23.0; extra == 'dev'
16
+ Requires-Dist: isort>=5.0; extra == 'dev'
17
+ Requires-Dist: mypy>=1.0; extra == 'dev'
18
+ Requires-Dist: pytest>=7.0; extra == 'dev'
19
+ Requires-Dist: responses>=0.23.0; extra == 'dev'
20
+ Description-Content-Type: text/markdown
21
+
22
+ # iskoldtbark
23
+
24
+ A secure, fully compliant Python client for the [Bark](https://github.com/Finb/Bark) push notification service.
25
+
26
+ ## Features
27
+
28
+ - **Full API V2 Compliance**: Uses the official `POST /push` REST API with structured JSON payloads.
29
+ - **Maximum Security**: Supports E2E encryption using AES-256-GCM and AES-256-CBC.
30
+ - **Dynamic IV Generation**: Generates a secure, random Initialization Vector (IV) for every request to prevent replay attacks and ensure cryptographic best practices.
31
+ - **Strict Validation**: Validates all payload parameters before sending.
32
+ - **Multi-User & Groups**: Manage many named recipient devices, each with its own
33
+ per-user encryption key, organize them into recipient groups, and broadcast to a
34
+ whole group in one command.
35
+
36
+ ## Installation
37
+
38
+ ```bash
39
+ pip install iskoldtbark
40
+ ```
41
+ *(Note: If not published, you can install via `pip install .` in this directory)*
42
+
43
+ ## Quick Start
44
+
45
+ ### Basic Notification
46
+
47
+ ```python
48
+ from iskoldtbark import BarkClient
49
+
50
+ client = BarkClient("YOUR_DEVICE_KEY")
51
+ client.push(
52
+ title="Hello",
53
+ body="This is a test notification.",
54
+ level="active",
55
+ badge=1,
56
+ )
57
+ ```
58
+
59
+ ### One-liner
60
+
61
+ ```python
62
+ import iskoldtbark
63
+
64
+ # Uses the default user from ~/.iskoldtbark/config.json (encryption applied automatically)
65
+ iskoldtbark.send("Deploy finished", title="CI", level="timeSensitive")
66
+
67
+ # Or supply a device key directly
68
+ iskoldtbark.send("Hello", "YOUR_DEVICE_KEY", title="Hi")
69
+ ```
70
+
71
+ ### Encrypted Notification (AES-256-GCM)
72
+
73
+ Ensure you have configured AES-256-GCM in your Bark App (Servers → Encryption Settings).
74
+
75
+ ```python
76
+ from iskoldtbark import BarkClient, EncryptionConfig, CryptoAlgorithm
77
+
78
+ # Pass encryption directly in the constructor — no separate set_encryption() call needed.
79
+ client = BarkClient(
80
+ "YOUR_DEVICE_KEY",
81
+ encryption=EncryptionConfig(
82
+ key=b"12345678901234567890123456789012", # 32 bytes for AES-256
83
+ algorithm=CryptoAlgorithm.AES_256_GCM,
84
+ ),
85
+ )
86
+ client.push(body="This payload is fully encrypted.", title="Top Secret")
87
+ ```
88
+
89
+ ### All payload parameters
90
+
91
+ ```python
92
+ client.push(
93
+ body="Deployment finished.", # required
94
+ title="CI",
95
+ subtitle="main branch",
96
+ markdown="**bold** _italic_", # overrides rendered body
97
+ level="timeSensitive", # active | timeSensitive | passive | critical
98
+ volume=5, # 0–10, for critical alerts
99
+ badge=3,
100
+ sound="minuet.caf",
101
+ icon="https://example.com/icon.png",
102
+ image="https://example.com/screenshot.png",
103
+ group="Deploys", # iOS notification group (UI grouping)
104
+ url="https://github.com/run/123",
105
+ call="1", # repeat sound for 30 s
106
+ autoCopy="1",
107
+ copy="text to copy",
108
+ isArchive="1",
109
+ ttl=3600, # seconds until archived message is deleted
110
+ action="none", # tap does nothing
111
+ id="deploy-42", # stable ID for update/delete
112
+ delete="1", # remove notification with id="deploy-42"
113
+ )
114
+ ```
115
+
116
+ ### Utility endpoints
117
+
118
+ ```python
119
+ client.ping() # GET /ping — connectivity check
120
+ client.info() # GET /info — server version / build info
121
+ client.healthz() # GET /healthz — health status string
122
+ ```
123
+
124
+ ## Multi-User CLI
125
+
126
+ Each **user** is a named recipient Bark device with its own device key and (optional)
127
+ per-user encryption. Users can belong to many **recipient groups**, and you can
128
+ broadcast to a whole group at once.
129
+
130
+ ```bash
131
+ # Set up your primary device (a nickname is required) — generates an AES-256-GCM key
132
+ iskoldtbark init --nickname phone --device-key YOUR_DEVICE_KEY
133
+
134
+ # Add more recipients
135
+ iskoldtbark user add --nickname laptop --device-key OTHER_KEY
136
+ iskoldtbark user list
137
+
138
+ # Create a recipient group and add members (a user may join many groups)
139
+ iskoldtbark group create work --description "work devices"
140
+ iskoldtbark group add-user work phone
141
+ iskoldtbark group add-user work laptop
142
+
143
+ # Send to the default user, a specific user, or broadcast to a group
144
+ iskoldtbark send "Hello" # -> default user
145
+ iskoldtbark send "Hello" --user laptop # -> one user
146
+ iskoldtbark send "Build finished" --user-group work # -> every member of "work"
147
+
148
+ iskoldtbark set-default laptop # change the default recipient
149
+ iskoldtbark config # show the resolved configuration
150
+ ```
151
+
152
+ Group broadcasts encrypt and send to each recipient independently and **continue on
153
+ individual failures**, printing a per-recipient summary (`N succeeded, M failed`). The
154
+ command exits non-zero only when *every* recipient fails.
155
+
156
+ ### `--user-group` vs `--group`
157
+
158
+ These are two unrelated things and are fully orthogonal:
159
+
160
+ - **`--user-group <name>`** selects the **recipients** to broadcast to (a group of users).
161
+ - **`--group <string>`** is the unchanged Bark field that groups notifications in the iOS
162
+ app UI (`BarkPayload.group`).
163
+
164
+ ```bash
165
+ # Broadcast to recipient-group "work"; each message uses iOS UI grouping "Alerts"
166
+ iskoldtbark send "Deploy done" --user-group work --group Alerts
167
+ ```
168
+
169
+ ### Config & migration
170
+
171
+ Configuration lives at `~/.iskoldtbark/config.json`. An existing single-user config is
172
+ **auto-migrated** to the new multi-user format on first use (wrapped as one `default`
173
+ user, with no data loss); run `iskoldtbark migrate` to rewrite the file explicitly. The
174
+ `BARK_DEVICE_KEY` / `BARK_SERVER_URL` / `BARK_ENCRYPTION_*` environment variables still
175
+ override the **default** user.
@@ -0,0 +1,154 @@
1
+ # iskoldtbark
2
+
3
+ A secure, fully compliant Python client for the [Bark](https://github.com/Finb/Bark) push notification service.
4
+
5
+ ## Features
6
+
7
+ - **Full API V2 Compliance**: Uses the official `POST /push` REST API with structured JSON payloads.
8
+ - **Maximum Security**: Supports E2E encryption using AES-256-GCM and AES-256-CBC.
9
+ - **Dynamic IV Generation**: Generates a secure, random Initialization Vector (IV) for every request to prevent replay attacks and ensure cryptographic best practices.
10
+ - **Strict Validation**: Validates all payload parameters before sending.
11
+ - **Multi-User & Groups**: Manage many named recipient devices, each with its own
12
+ per-user encryption key, organize them into recipient groups, and broadcast to a
13
+ whole group in one command.
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ pip install iskoldtbark
19
+ ```
20
+ *(Note: If not published, you can install via `pip install .` in this directory)*
21
+
22
+ ## Quick Start
23
+
24
+ ### Basic Notification
25
+
26
+ ```python
27
+ from iskoldtbark import BarkClient
28
+
29
+ client = BarkClient("YOUR_DEVICE_KEY")
30
+ client.push(
31
+ title="Hello",
32
+ body="This is a test notification.",
33
+ level="active",
34
+ badge=1,
35
+ )
36
+ ```
37
+
38
+ ### One-liner
39
+
40
+ ```python
41
+ import iskoldtbark
42
+
43
+ # Uses the default user from ~/.iskoldtbark/config.json (encryption applied automatically)
44
+ iskoldtbark.send("Deploy finished", title="CI", level="timeSensitive")
45
+
46
+ # Or supply a device key directly
47
+ iskoldtbark.send("Hello", "YOUR_DEVICE_KEY", title="Hi")
48
+ ```
49
+
50
+ ### Encrypted Notification (AES-256-GCM)
51
+
52
+ Ensure you have configured AES-256-GCM in your Bark App (Servers → Encryption Settings).
53
+
54
+ ```python
55
+ from iskoldtbark import BarkClient, EncryptionConfig, CryptoAlgorithm
56
+
57
+ # Pass encryption directly in the constructor — no separate set_encryption() call needed.
58
+ client = BarkClient(
59
+ "YOUR_DEVICE_KEY",
60
+ encryption=EncryptionConfig(
61
+ key=b"12345678901234567890123456789012", # 32 bytes for AES-256
62
+ algorithm=CryptoAlgorithm.AES_256_GCM,
63
+ ),
64
+ )
65
+ client.push(body="This payload is fully encrypted.", title="Top Secret")
66
+ ```
67
+
68
+ ### All payload parameters
69
+
70
+ ```python
71
+ client.push(
72
+ body="Deployment finished.", # required
73
+ title="CI",
74
+ subtitle="main branch",
75
+ markdown="**bold** _italic_", # overrides rendered body
76
+ level="timeSensitive", # active | timeSensitive | passive | critical
77
+ volume=5, # 0–10, for critical alerts
78
+ badge=3,
79
+ sound="minuet.caf",
80
+ icon="https://example.com/icon.png",
81
+ image="https://example.com/screenshot.png",
82
+ group="Deploys", # iOS notification group (UI grouping)
83
+ url="https://github.com/run/123",
84
+ call="1", # repeat sound for 30 s
85
+ autoCopy="1",
86
+ copy="text to copy",
87
+ isArchive="1",
88
+ ttl=3600, # seconds until archived message is deleted
89
+ action="none", # tap does nothing
90
+ id="deploy-42", # stable ID for update/delete
91
+ delete="1", # remove notification with id="deploy-42"
92
+ )
93
+ ```
94
+
95
+ ### Utility endpoints
96
+
97
+ ```python
98
+ client.ping() # GET /ping — connectivity check
99
+ client.info() # GET /info — server version / build info
100
+ client.healthz() # GET /healthz — health status string
101
+ ```
102
+
103
+ ## Multi-User CLI
104
+
105
+ Each **user** is a named recipient Bark device with its own device key and (optional)
106
+ per-user encryption. Users can belong to many **recipient groups**, and you can
107
+ broadcast to a whole group at once.
108
+
109
+ ```bash
110
+ # Set up your primary device (a nickname is required) — generates an AES-256-GCM key
111
+ iskoldtbark init --nickname phone --device-key YOUR_DEVICE_KEY
112
+
113
+ # Add more recipients
114
+ iskoldtbark user add --nickname laptop --device-key OTHER_KEY
115
+ iskoldtbark user list
116
+
117
+ # Create a recipient group and add members (a user may join many groups)
118
+ iskoldtbark group create work --description "work devices"
119
+ iskoldtbark group add-user work phone
120
+ iskoldtbark group add-user work laptop
121
+
122
+ # Send to the default user, a specific user, or broadcast to a group
123
+ iskoldtbark send "Hello" # -> default user
124
+ iskoldtbark send "Hello" --user laptop # -> one user
125
+ iskoldtbark send "Build finished" --user-group work # -> every member of "work"
126
+
127
+ iskoldtbark set-default laptop # change the default recipient
128
+ iskoldtbark config # show the resolved configuration
129
+ ```
130
+
131
+ Group broadcasts encrypt and send to each recipient independently and **continue on
132
+ individual failures**, printing a per-recipient summary (`N succeeded, M failed`). The
133
+ command exits non-zero only when *every* recipient fails.
134
+
135
+ ### `--user-group` vs `--group`
136
+
137
+ These are two unrelated things and are fully orthogonal:
138
+
139
+ - **`--user-group <name>`** selects the **recipients** to broadcast to (a group of users).
140
+ - **`--group <string>`** is the unchanged Bark field that groups notifications in the iOS
141
+ app UI (`BarkPayload.group`).
142
+
143
+ ```bash
144
+ # Broadcast to recipient-group "work"; each message uses iOS UI grouping "Alerts"
145
+ iskoldtbark send "Deploy done" --user-group work --group Alerts
146
+ ```
147
+
148
+ ### Config & migration
149
+
150
+ Configuration lives at `~/.iskoldtbark/config.json`. An existing single-user config is
151
+ **auto-migrated** to the new multi-user format on first use (wrapped as one `default`
152
+ user, with no data loss); run `iskoldtbark migrate` to rewrite the file explicitly. The
153
+ `BARK_DEVICE_KEY` / `BARK_SERVER_URL` / `BARK_ENCRYPTION_*` environment variables still
154
+ override the **default** user.
@@ -0,0 +1,47 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "iskoldtbark"
7
+ version = "0.1.0"
8
+ description = "A secure, official-compliant Python client for the Bark push notification service."
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
11
+ license = { text = "MIT" }
12
+ authors = [
13
+ { name = "Developer", email = "developer@example.com" }
14
+ ]
15
+ classifiers = [
16
+ "Programming Language :: Python :: 3",
17
+ "License :: OSI Approved :: MIT License",
18
+ "Operating System :: OS Independent",
19
+ "Topic :: Communications",
20
+ ]
21
+ dependencies = [
22
+ "requests>=2.25.0",
23
+ "cryptography>=41.0.0",
24
+ ]
25
+
26
+ [project.scripts]
27
+ iskoldtbark = "iskoldtbark.cli:main"
28
+
29
+ [project.optional-dependencies]
30
+ dev = [
31
+ "pytest>=7.0",
32
+ "responses>=0.23.0",
33
+ "black>=23.0",
34
+ "isort>=5.0",
35
+ "mypy>=1.0",
36
+ ]
37
+
38
+ [tool.hatch.build.targets.wheel]
39
+ packages = ["src/iskoldtbark"]
40
+
41
+ [tool.black]
42
+ line-length = 100
43
+ target-version = ["py38"]
44
+
45
+ [tool.isort]
46
+ profile = "black"
47
+ line_length = 100
@@ -0,0 +1,40 @@
1
+ from .client import BarkClient, send
2
+ from .config import (
3
+ BarkConfig,
4
+ ConfigManager,
5
+ MultiUserConfig,
6
+ RecipientGroup,
7
+ UserConfig,
8
+ make_encryption_config,
9
+ )
10
+ from .crypto import CryptoAlgorithm, EncryptionConfig
11
+ from .exceptions import (
12
+ BarkAPIError,
13
+ BarkConfigError,
14
+ BarkCryptoError,
15
+ BarkError,
16
+ BarkValidationError,
17
+ )
18
+ from .models import BarkPayload
19
+ from .notifier import BarkSendResult, UserNotifier
20
+
21
+ __all__ = [
22
+ "BarkClient",
23
+ "EncryptionConfig",
24
+ "CryptoAlgorithm",
25
+ "BarkPayload",
26
+ "BarkError",
27
+ "BarkAPIError",
28
+ "BarkCryptoError",
29
+ "BarkValidationError",
30
+ "BarkConfigError",
31
+ "ConfigManager",
32
+ "BarkConfig",
33
+ "UserConfig",
34
+ "RecipientGroup",
35
+ "MultiUserConfig",
36
+ "make_encryption_config",
37
+ "UserNotifier",
38
+ "BarkSendResult",
39
+ "send",
40
+ ]