Skip to content

feat(mobile): add encrypted notifications through push relay - #206

Merged
ZingerLittleBee merged 72 commits into
mainfrom
feat/mobile-push-integration
Oct 5, 2026
Merged

ZingerLittleBee merged 72 commits into
mainfrom
feat/mobile-push-integration

Conversation

@ZingerLittleBee

@ZingerLittleBee ZingerLittleBee commented Oct 3, 2026 •

Copy link
Copy Markdown
Owner

Summary

Server-originated encrypted mobile notifications through ServerBee Server -> public stateless Cloudflare Workers Relay -> APNs -> iOS Notification Service Extension. The Server owns login, installation/account authorization, category subscriptions and the durable 30-minute delivery window; AES-256-GCM content encryption stays on the Server and decryption stays in the phone's Notification Service Extension.

Architecture decision update (2026-10-03)

This PR implements the approved simpler design. The earlier App Attest/stateful-grant architecture and its acceptance requirements are superseded:

  • Expose one public POST /v1/send Worker endpoint taking the APNs token/environment, event identity/expiry and the existing unchanged AEAD envelope
  • Remove App Attest, strict app-version/distribution verification, challenges, grant issuance/inspection/renewal/revocation and Relay SQLite, with no renamed replacement authorization system
  • Register iOS push directly through authenticated Server /api/mobile/push/encrypted-register; preserve installation ownership, key lifecycle, logout/revocation, account isolation and authenticated typed-target navigation
  • Use operator-controlled topic/environment bindings, fixed APNs hosts, WebCrypto JWT signing/reuse and Workers fetch; enforce hard streaming body/payload bounds, timeouts, bounded concurrency and bounded best-effort source/target/instance-wide limits
  • Preserve alert trigger/recovery, administrator security events, final task-failure summaries, optional task success, existing external channels, one final task summary per run, and original outbox expiry/retry policy

The public endpoint deliberately accepts residual abuse risk. Knowing a valid token permits junk/replayed submissions that can leave a generic notification visible; arbitrary or self-owned-token requests can consume Relay/APNs quota. AEAD protects the encrypted business content, not public endpoint abuse. In-memory limits are per-instance, reset with Workers isolates and do not establish strict global quota enforcement. The Relay receives delivery/envelope metadata and ciphertext, never notification plaintext or content keys; diagnostics must not expose tokens, keys, signing material or request bodies.

Official app identity (2026-10-03)

The official main app, Notification Service Extension and test bundle identifiers are app.serverbee, app.serverbee.notifications and app.serverbee.tests. Private/shared Keychain groups use $(AppIdentifierPrefix)app.serverbee and $(AppIdentifierPrefix)app.serverbee.push. Historical com.serverbee.mobile / com.serverbee.mobile.push Keychain service labels are intentionally retained for stored-credential compatibility; they are not bundle identifiers. Static identity-drift checks and testOfficialIdentityReadsHistoricalServiceInDefaultPrivateGroup passed. Signed-device upgrade continuity remains unverified.

Validation status

The simplification and official app identity correction are implemented on feat/mobile-push-integration at 22c828c4517734b0814240ca4bbe751d126ffa3d. All 17 current PR checks are green, with no pending or failed checks at the final verification on 2026-10-03 at 19:53 UTC. Evidence below is for this exact head:

  • Main CI: all nine jobs passed, including Rust test shards, lint/checks and frontend checks. The mobile_push_integration suite passed all 88 tests with none ignored. Official API generation and the zero-drift gate passed
  • iOS and Rust-to-Worker integration: both jobs passed; 424 iOS tests executed with zero failures and no XCTest skips. Two real Rust integration tests generated the Worker ciphertext traces, and all three formerly skipped native consumers executed and passed, covering actual Notification Service Extension rendering and authenticated cold-tap routing
  • Worker runtime: 61 workerd tests plus one native-workerd HTTP/TCP-reset cancellation regression passed; Worker/fixture type checks and Wrangler production dry-run passed (15.98 KiB, 4.92 KiB gzip). The cancellation regression includes a flag-off negative control for the production enable_request_signal setting
  • Documentation contracts and commit attribution passed
  • Final regression coverage preserves the original queued ciphertext, registration revision and expiry when the same installation/token/environment/key/deployment tuple is registered again; a changed tuple still fences stale work

The earlier App Attest/grant head 1697f1cced72686d17830897b8f6b6041707f655 and its validation remain historical context only.

Deployment/configuration checkpoint (2026-10-03, 19:48 UTC): The existing Worker deployment is active. APNS_TOPIC is now app.serverbee; the optional APNS_ENVIRONMENTS override was removed, so the configured default permits sandbox and production. Existing encrypted credential bindings were retained. A safe empty-object POST now returns 400 InvalidRequest instead of 503 RelayNotConfigured. This establishes accepted configuration shape only, not signing-key validity or APNs provider acceptance. No request to Apple's APNs provider was made. The Worker runtime bundle is byte-identical between ae5add3 and 22c828c, so no code redeploy was needed.

Live APNs sandbox/production provider acceptance and delivery, signed-device upgrade continuity, and signed physical-device foreground/background/terminated presentation and taps remain NOT RUN. They require an authorized isolated HTTPS Server/Worker, Apple configuration and credentials, and matching App/NSE provisioning and effective entitlements on a physical device. Simulator/fixture/provider-receipt evidence must stay separate from actual device presentation and navigation. App Attest is no longer a prerequisite. See tests/manual/mobile-push-integration.md and the English/Chinese push-relay deployment guides for the remaining acceptance matrix.

Historical validation of the superseded App Attest/grant implementation

Validation at 2532e6f2315f0b2b735ebd10190738c100db6c16: 1,544 Server library tests and 270 Server integration tests passed; iOS simulator suites passed 404 tests and 62 selected zh-Hans tests with zero failures or skips; Relay passed 26 tests and secret-transport boundaries passed six cases. Workspace check, strict Clippy, official API generation with zero drift, Web build/types, changed Rust formatting, changed Swift strict lint, and documentation build/types/contracts/routes/browser checks passed. Nine affected checks passed again after integration, including fresh real Server-to-Relay traces and seven actual native consumer/lifecycle tests. Each candidate and integration conflict resolution received independent fixed-SHA review.

This record is retained as prior work only. It does not establish the refactored Worker contract, deployment or real APNs/device behavior. Historical local simulator validation used Xcode/iOS SDK 27 and did not establish the CI Xcode 16.4 result.

Refs #196, #197, #198, #199, #200, #201, #202, #203, #204, #205.

Capture the agreed notification design and testing boundaries published in #196.
Acquire the SQLite writer lock before reading user mutation guards to avoid busy upgrades against delivery workers. Recover unconfirmed test admission with an owned lookup and the same UUID across revision changes and restarts.

Refs: #200

This branch was successfully deployed

1 active deployment
Preview — f57c3d6f Deployed Oct 5, 2026 by vercel[bot]
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