Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
f1c9d3f
trying windows pipeline
daslearning Nov 23, 2026
9143101
test the kivy build on windows pipeline
daslearning Nov 23, 2026
182d068
test auto release notes
daslearning Nov 23, 2026
f3c7ba1
both linux & windows pipelines seem to be ready
daslearning Nov 23, 2026
a18b38b
docs: design the remote settings and control API
japperJ Nov 26, 2026
1c97cd6
test: add off-device API harness and CI
japperJ Nov 26, 2026
6cfef13
feat: expose authenticated health and settings reads
japperJ Nov 26, 2026
a4aaf95
feat: allow settings to be changed over the network
japperJ Nov 26, 2026
30c9673
fix: merge local settings saves over a fresh read
japperJ Nov 26, 2026
5d33ef9
feat: report forwarding health through the API
japperJ Nov 26, 2026
80630b6
feat: validate a Webhook target before saving
japperJ Nov 26, 2026
84a9820
feat: restart the server onto a new port
japperJ Nov 26, 2026
2fe6a0c
feat: give each integration its own API key
japperJ Nov 26, 2026
102a8e1
feat: keep Inbound SMS through a longer proxy outage
japperJ Nov 26, 2026
1c8be82
fix: reject credentialed webhook targets
japperJ Nov 26, 2026
869023d
fix: preserve remote Settings on permission confirmation
japperJ Nov 26, 2026
3e32c25
fix: keep status truthful under malformed state
japperJ Nov 26, 2026
8b9fd80
test: cover stale Settings form saves
japperJ Nov 26, 2026
eaabe73
Add Pydantic request models for remote API
japperJ Nov 26, 2026
6116a77
release: ship 1.2.0
japperJ Nov 26, 2026
0a447b8
fix: widen Webhook URL and secret fields
japperJ Nov 26, 2026
91dc587
review: address standards findings
japperJ Nov 26, 2026
3a3ac60
fix: address spec review findings
japperJ Nov 26, 2026
3274b7d
fix: address PR review comments
japperJ Nov 26, 2026
12d8fd3
Merge pull request #22 from japperJ/feat/remote-settings-api
sdas92 Nov 27, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions .github/workflows/linuxExe.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
- main
paths:
- 'app/**'
workflow_dispatch:

# Top-level permissions
permissions:
Expand Down Expand Up @@ -79,19 +80,32 @@ jobs:
pyinstaller desktopCli.spec
pyinstaller desktopGui.spec

#- name: Upload artifact
# uses: actions/upload-pages-artifact@v3
# with:
# path: './flasher'
- name: Extract changelog for release
env:
VERSION: ${{ steps.set_version.outputs.app_version }}
run: |
python -c "
import os, re
ver = os.environ['VERSION'].lstrip('v')
with open('CHANGELOG.md', 'r', encoding='utf-8') as f:
text = f.read()
# Match from '### 1.1.0' until the next '### ' or '## ' heading
pattern = rf'(?m)^###\s+v?{re.escape(ver)}\b.*?\n(.*?)(?=^###?\s|\Z)'
match = re.search(pattern, text, re.DOTALL)
notes = match.group(1).strip() if match else f'Release {ver}'
with open('RELEASE_NOTES.md', 'w', encoding='utf-8') as f:
f.write(notes)
"

- name: Create GitHub Release
uses: softprops/action-gh-release@v3
with:
tag_name: ${{ steps.set_version.outputs.app_version }}
name: ${{ steps.set_version.outputs.app_version }}
body_path: RELEASE_NOTES.md
draft: false
prerelease: true
generate_release_notes: true
generate_release_notes: false
files: |
app/dist/openSmsCli
app/dist/OpenSmsApp
46 changes: 46 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Runs the off-device test suite on Linux without Android.

name: 'Tests'

on:
push:
branches:
- main
- develop
paths:
- 'app/**'
- '.github/workflows/tests.yml'
pull_request:
paths:
- 'app/**'
- '.github/workflows/tests.yml'
workflow_dispatch:

permissions:
contents: read

jobs:
linux_tests:
name: 'Unit tests (Linux)'
runs-on: 'ubuntu-24.04'

steps:

- name: GIT Checkout
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v7
with:
python-version: '3.13'
cache: 'pip'

- name: Install Dependencies
working-directory: ./app
run: |
pip install fastapi uvicorn psutil pyserial -r requirements-dev.txt

- name: Run unit tests
working-directory: ./app
run: |
python -m unittest discover -s tests -p "test_*.py" -v
80 changes: 38 additions & 42 deletions .github/workflows/winExe.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ name: 'Windows Executables'

on:

#push:
# branches:
# - main
# paths:
# - 'app/**'
push:
branches:
- main
paths:
- 'app/**'
workflow_dispatch:

# Top-level permissions
Expand All @@ -29,10 +29,9 @@ jobs:
id: 'git-checkout'
uses: "actions/checkout@v4"

#- name: Install Dependencies
# id: 'install_prereq'
# run: |
# # <command>
# 1. Install Mesa3D so the headless runner supports OpenGL 2.0+
- name: Setup Mesa3D for OpenGL 2.0+
uses: ssciwr/setup-mesa-dist-win@v3

- name: Set version
id: 'set_version'
Expand Down Expand Up @@ -62,26 +61,11 @@ jobs:
run: |
cd app
python --version
pip install -r req_cli.txt
python -c "import sys; print(sys.executable)"

#- name: Configure Windows graphics backend
# shell: pwsh
# run: |
# cd app
# (Get-Content main.py -Raw).Replace(
# "os.environ['KIVY_GL_BACKEND'] = 'sdl2'",
# "os.environ['KIVY_GL_BACKEND'] = 'angle_sdl2'"
# ) | Set-Content main.py -NoNewline
# Get-Content main.py | Select-Object -First 5

#- name: Check Windows graphics environment
# shell: pwsh
# run: |
# cd app
# Get-CimInstance Win32_VideoController |
# Format-Table Name, DriverVersion, Status
# python -c "import os; os.environ['KIVY_GL_BACKEND']='angle_sdl2'; from kivy.core.window import Window; print(Window)"
pip install -r req_desktop.txt
python -c "
import kivy
print('Kivy:', kivy.__version__)
"

- name: Test CLI imports
shell: pwsh
Expand All @@ -95,27 +79,39 @@ jobs:
cd app
pyinstaller --clean --noconfirm desktopCli.spec

#- name: PyInstaller GUI
# id: 'py_gui'
# shell: pwsh
# run: |
# cd app
# $env:KIVY_GL_BACKEND = "sdl2"
# pyinstaller --clean --noconfirm desktopGui.spec
- name: PyInstaller GUI
id: 'py_gui'
shell: pwsh
run: |
cd app
pyinstaller --clean --noconfirm desktopGui.spec

#- name: Upload artifact
# uses: actions/upload-pages-artifact@v3
# with:
# path: './flasher'
- name: Extract changelog for release
env:
VERSION: ${{ steps.set_version.outputs.app_version }}
run: |
python -c "
import os, re
ver = os.environ['VERSION'].lstrip('v')
with open('CHANGELOG.md', 'r', encoding='utf-8') as f:
text = f.read()
# Match from '### 1.1.0' until the next '### ' or '## ' heading
pattern = rf'(?m)^###\s+v?{re.escape(ver)}\b.*?\n(.*?)(?=^###?\s|\Z)'
match = re.search(pattern, text, re.DOTALL)
notes = match.group(1).strip() if match else f'Release {ver}'
with open('RELEASE_NOTES.md', 'w', encoding='utf-8') as f:
f.write(notes)
"

- name: Create GitHub Release
uses: softprops/action-gh-release@v3
with:
tag_name: ${{ steps.set_version.outputs.app_version }}
name: ${{ steps.set_version.outputs.app_version }}
body_path: RELEASE_NOTES.md
draft: false
prerelease: true
generate_release_notes: true
generate_release_notes: false
files: |
app/dist/openSmsCli.exe
#app/dist/OpenSmsApp.exe
app/dist/OpenSmsApp.exe
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## Changes

### 1.2.0
- Add a bearer-authenticated remote Settings and control API: `GET /api/health`, `GET /api/status`, `GET/PUT /api/settings`, `POST /api/webhook/test`, and `POST /api/server/restart`, with Revision-based optimistic concurrency and human-readable validation errors.
- Add named API keys with `sms:write` and `settings:write` Scopes, immediate revocation, and phone-key rotation that leaves proxy keys intact.
- Make Webhook retry timeout, attempts, backoff, and Outbox capacity live Settings, so a longer proxy outage does not lose Inbound SMS; reject credentialed Webhook targets.
- Keep the on-device UI consistent with remote changes through fresh read-merge-write saves; `GET /api/status` reports forwarding health and warnings.

### 1.1.0
- Forward received SMS to a configurable webhook (Android), with optional HMAC-SHA256 signing, ordered delivery, retries and a persisted outbox. See the [README](./README.md#-receiving-sms-android).
- Show the last webhook delivery result and a test button in Settings; log inbound SMS and delivery outcomes.
Expand Down
20 changes: 20 additions & 0 deletions GLOSSARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,23 @@ _Avoid_: retry, send, try
**Outbox**:
The persisted queue of Webhooks that are waiting to be delivered.
_Avoid_: queue, buffer, backlog

**Settings**:
The operator-chosen configuration that OpenSMS keeps across restarts: the API port, whether the server starts at launch, and the Webhook configuration.
_Avoid_: config, preferences, options

**Revision**:
The identifier of one persisted version of Settings. A write that expects an older Revision than the stored one is refused.
_Avoid_: version, generation, counter

**Scope**:
A permission attached to an API key that allows a class of operations, such as sending SMS or changing Settings.
_Avoid_: role, permission level, grant

**API key**:
The secret credential an external client presents to call the OpenSMS API.
_Avoid_: token, password, secret

**Restart**:
Replacing the running API server with a new one that uses the current Settings, notably the port.
_Avoid_: reload, reboot, bounce
73 changes: 70 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ You may need to run this first to generate the first API Key.
```bash
python openSmsCli.py interactive --serial /dev/ttyUSB0 # change your serial port, on windows: COM1 (example)

# generate a new API key
# replace this phone's API key (other keys keep working)
newkey

# get other interactive commands
Expand Down Expand Up @@ -132,14 +132,81 @@ curl -i -X POST 'http://127.0.0.1:9292/sms/' \
-d '{"number": "+1234567890", "text": "Hello from OpenSMS API!"}'
```

### 🔐 Remote Settings and control API

The API server can also read and change Settings, manage API keys, test the Webhook, and restart the server. This is meant for a proxy or automation on the **same LAN or VPN** as the phone. The API uses bearer keys over plain HTTP, with no TLS or CORS, so never expose the port to the internet; use a VPN or an authenticated tunnel for remote access.

Every `/api/` route, including `GET /api/health`, requires an API key with the `settings:write` Scope. `POST /sms/` requires `sms:write`.

| Scope | Allows |
| --- | --- |
| `sms:write` | `POST /sms/` |
| `settings:write` | every `/api/` route: health, status, Settings, key management, Webhook test, Restart |

The first API key is created from the phone UI the first time you tap Start Server. Create a separate key for each integration; the raw key is returned only once. Set it once in your shell:

```bash
export OSMS_KEY='osms_…'

curl -sS -X POST 'http://192.168.1.50:9292/api/keys' \
-H "Authorization: Bearer $OSMS_KEY" \
-H 'Content-Type: application/json' \
-d '{"name": "sms-proxy", "scopes": ["sms:write"]}'
```

`GET /api/keys` lists keys without hashes, and `DELETE /api/keys/{id}` revokes one immediately. The last remaining key cannot be deleted.

Check the phone and read Settings:

```bash
curl -sS -H "Authorization: Bearer $OSMS_KEY" \
'http://192.168.1.50:9292/api/health'

curl -sS -H "Authorization: Bearer $OSMS_KEY" \
'http://192.168.1.50:9292/api/settings'
```

`PUT /api/settings` replaces the full writable subset, so send every field you want to keep. Include the `revision` from `GET` for optimistic concurrency; a stale Revision returns `409`.

```bash
curl -sS -X PUT 'http://192.168.1.50:9292/api/settings' \
-H "Authorization: Bearer $OSMS_KEY" \
-H 'Content-Type: application/json' \
-d '{
"revision": 7,
"port": 9292,
"boot": true,
"webhook": {
"enabled": true,
"url": "https://proxy.example.lan/hooks/opensms",
"timeout": 10,
"max_attempts": 3,
"backoff": [5, 30],
"capacity": 100
}
}'
```

Omit `webhook.secret` to keep the stored secret, send `""` to clear it, or send a new string to replace it. Webhook and retry changes take effect immediately. Changing `boot` is read at the next app launch; it does not start or stop the current service. A port change is two-step: the response sets `restart_required`, then call:

```bash
curl -sS -X POST 'http://192.168.1.50:9292/api/server/restart' \
-H "Authorization: Bearer $OSMS_KEY"
```

Restart requires the background service loop; the standalone CLI runs the
server directly and refuses Restart with `409`.

`GET /api/status` reports the bound and configured port, network addresses, Outbox depth, the last Delivery attempt, and warnings (for example when forwarding is disabled or the Outbox is near capacity). `POST /api/webhook/test` tests a Webhook target without saving it. The full contract, error codes, and persisted schema are in [docs/remote-api.md](./docs/remote-api.md).

## 📥 Receiving SMS (Android)

OpenSMS can forward every SMS received by the phone to your own HTTP endpoint as a webhook. Receiving works independently of the API server: it runs in the same background service, so the API can be stopped while webhooks keep flowing.

### Configure it

1. Open `Settings` and find the **Webhook (Inbound SMS)** section.
2. Enter the **Webhook URL** (`http://` or `https://`).
2. Enter the **Webhook target** (`http://` or `https://`) without `username:password@` userinfo.
3. Optionally set a **Signing Secret** to sign every request.
4. Enable the switch and tap **Save**.
5. Tap **Send Test Webhook** to check the endpoint. This sends `event: "webhook.test"`.
Expand All @@ -153,7 +220,7 @@ Every Inbound SMS produces one `POST` with a JSON body:
```http
POST /your-hook HTTP/1.1
Content-Type: application/json
User-Agent: OpenSMS/1.1.0
User-Agent: OpenSMS/1.2.0
X-OpenSMS-Event: sms.received
X-OpenSMS-Delivery: 6f1c2f5e-0d7a-4c55-9f0e-2b1c8b7f0a11
X-OpenSMS-Signature: sha256=...
Expand Down
Loading
Loading