Skip to content

th-c561f1: auto-provision VAPID keys so Web Push works out of the box - #335

Merged
brentrager merged 2 commits into
mainfrom
th-c561f1-vapid
Aug 4, 2026
Merged

th-c561f1: auto-provision VAPID keys so Web Push works out of the box#335
brentrager merged 2 commits into
mainfrom
th-c561f1-vapid

Conversation

@brentrager

Copy link
Copy Markdown
Contributor

Problem

"Enable notifications" did nothing. The daemon only read VAPID keys from SMOOTH_VAPID_PUBLIC/SMOOTH_VAPID_PRIVATE — unset on a normal install — so /push/key returned 503 and the button silently no-op'd (surfaced honestly in #333; this makes it actually work).

Fix

The daemon now generates a P-256 VAPID keypair on first run (pure-Rust p256, already in the tree via web-push), persists it to ~/.smooth/vapid.json (mode 600), and serves it — push enrolls with zero setup.

  • Precedence unchanged where it matters: explicit SMOOTH_VAPID_* env → persisted vapid.json → freshly generated pair.
  • Windows stays disabled (no push sender there; the keygen is #[cfg(not(windows))]).
  • SMOOTH_VAPID_FILE overrides the path (used by tests so they never touch ~/.smooth).

Verification

  • cargo test -p smooai-smooth-daemon push:: — 4/4 pass, including:
    • generated_keys_are_valid_vapid — public = 65-byte uncompressed point (0x04…), private = 32-byte scalar, and the key round-trips through web-push's VapidSignatureBuilder::from_base64.
    • load_or_generate_is_stable — persists on first run, reuses on the next.
    • windows_resolves_to_no_keys.
  • clippy-clean on the new code; cargo fmt clean.

Rollout

Once merged, redeploy to smoo-hub (scripts/smoo-hub/install-app.sh) and its Big Smooth will have working push; the client's "Enable notifications" then enrolls this device.

🤖 Generated with Claude Code

Notifications no-op'd because the daemon only read VAPID keys from
SMOOTH_VAPID_PUBLIC/_PRIVATE (unset on a normal install) → /push/key 503 →
dead 'Enable notifications' button. Now the daemon generates a P-256 keypair
on first run (pure-Rust p256), persists it to ~/.smooth/vapid.json (mode 600),
and serves it. Precedence: explicit env → persisted file → fresh pair. Windows
stays disabled. SMOOTH_VAPID_FILE overrides the path. +3 tests incl. a
web-push VapidSignatureBuilder round-trip proving the key format.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L3xMBWMtMRNayBC2GjHntk
@changeset-bot

changeset-bot Bot commented Aug 4, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7ca351b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@smooai/smooth Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@brentrager
brentrager merged commit 654a2d2 into main Aug 4, 2026
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant