fix(login): identity preview on primary splash, lenient hex parsing#303
Open
dmnyc wants to merge 1 commit into
Open
fix(login): identity preview on primary splash, lenient hex parsing#303dmnyc wants to merge 1 commit into
dmnyc wants to merge 1 commit into
Conversation
…tighter error Two related login bugs from #226 + #227. #227 — identity preview missing from primary login. The splash sheet `NostrLoginSheet` and the secondary `LoginView` (Add Account) used to be separate implementations; only `LoginView` rendered a live avatar + display name + nip05 preview from the pasted nsec. Extract the preview into a shared `NsecIdentityPreview` SwiftUI view that owns its own debounced relay lookup, and use it from both surfaces. #226 — hex private key login fails despite the error message saying hex is supported. The path actually worked end-to-end, but `parseNsec` only accepted a literal 64-char string with no prefix and no internal whitespace. Keys copied from wallets or terminals often arrive with a leading `0x` / `0X` prefix or surrounding spaces and silently failed validation. `parseNsec` now strips both before the length check. Also: - Splash error wording rewritten so the user can tell which formats the field accepts ("nsec (\"nsec1…\"), npub / nprofile to browse watch-only, or a 64-character hex private key") and the `LoginView` variant tracks. - Splash sheet detent bumped from `.medium` to a custom `.height(500)` so the ostrich isn't crowded against the top edge and the new preview card fits between the input and the Log In button without clipping the lower controls. `.large` stays as a secondary detent. - Splash description line shortened from two sentences to one and pinned with `.fixedSize(vertical: true)` so it never truncates with an ellipsis at narrow widths. - Splash button stack regrouped: the two federated identity options (Apple, Google) stay tight at 8pt; the Nostr button gets a 16pt gap below them so it reads as its own choice rather than a third entry in the federated list. Closes #226. Closes #227.
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.
Summary
Closes #226 (hex private-key login appears to fail despite the error message saying hex is supported) and #227 (account preview missing from the primary login screen).
Changes
Identity preview shared across both login surfaces. The splash sheet (
NostrLoginSheetinSplashView.swift) and the secondary login (LoginViewfor Add Account) were separate implementations; only the secondary one rendered a live avatar + display name + nip05 preview. Extracted the preview into a newNsecIdentityPreviewSwiftUI view that owns its own debounced relay lookup, and now both surfaces use it.Lenient hex parsing.
NostrKey.parseNsecalready supported a raw 64-char hex private key but rejected anything with a0x/0Xprefix or internal whitespace — keys copied from wallets or terminals often arrive in those shapes and were silently failing. Both are now stripped before the length check.Tighter error wording. Both screens previously said "Invalid key. Enter an nsec or hex private key." which gave the user no signal about why a hex paste failed. Reworded to spell out the accepted formats explicitly.
Splash layout refinements (came out of testing the new preview):
.mediumto a custom.height(500)so the ostrich isn't crowded against the top and the preview card fits between input + Log In without clipping the lower controls..largestays as a secondary detent..fixedSize(vertical: true)so it never truncates with an ellipsis.Test plan
0xprefix logs in successfullyCloses #226. Closes #227.