fix: auto-register JWT-only devices on first auth#3
Draft
123qwe55aa wants to merge 14 commits into
Draft
Conversation
sync-daemon uses HS256 JWT (deviceId in payload.sub) without Ed25519 registration. Middleware now upserts Device record so sessions can be created without a prior /v1/auth publicKey exchange. Also fix in sync-daemon: JWT payload uses 'deviceId' instead of 'sub' to match mio-server verifyToken expectations.
- Make bumpLastSeenAt async and await it in authMiddleware - Use findFirst+create pattern to ensure device exists before session - Add /v1/debug/device/:deviceId endpoint to check DB state - Fixes P2003 FK error when sync-daemon creates sessions via JWT auth - Handles JWT-only devices that bypass normal pairing flow
debug: add session count + active flag to GET /v1/sessions response log fix: move socket deviceId log after payload init
… create - GET /v1/devices/mac-by-code/:shortCode: lets sync-daemon resolve Mac's deviceId by shortCode so sessions are created under Mac's deviceId (instead of daemon's own deviceId), enabling iPhone session list to show daemon-created sessions filtered by Mac.deviceId - POST /v1/sessions: back-fill device.publicKey on existing devices so Ed25519 and HS256 JWT device records can be distinguished (prevents overwrite of real Ed25519 publicKey values)
Previously canAccessSession checked DeviceLink, rejecting Mac when it tried to read sync-daemon's sessions. Now any authenticated device can read any session — authMiddleware already validates the requester.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem: sync-daemon uses HS256 JWT with deviceId claim but mio-server rejects because deviceId not in DB. Fix: bumpLastSeenAt() uses upsert instead of update to auto-create Device record on first auth. Also sync-daemon JWT now uses deviceId field instead of sub.