damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

commit f08efd7e30543f49fc073511ed7082757a810da5
parent fb2a69acd84e45223917f529351c236e1e636496
Author: William Casarin <jb55@jb55.com>
Date:   Fri, 14 Jul 2023 09:47:28 -0700

nip05: rename nip05 verification to nostr address

nip05 identifiers and nip05 verification is too confusing, and also
wrong. Let's use the "nostr address" terminology.

Suggested-by: Derek Ross
Suggested-by: Semisol <hi@semisol.dev>
Changelog-Changed: Rename NIP05 to "nostr address"

Diffstat:
Mdamus/Views/Profile/EditMetadataView.swift | 38++++++++++++++++++++++++++++++--------
1 file changed, 30 insertions(+), 8 deletions(-)

diff --git a/damus/Views/Profile/EditMetadataView.swift b/damus/Views/Profile/EditMetadataView.swift @@ -158,21 +158,23 @@ struct EditMetadataView: View { } Section(content: { - TextField(NSLocalizedString("jb55@jb55.com", comment: "Placeholder example text for identifier used for NIP-05 verification."), text: $nip05) + TextField(NSLocalizedString("jb55@jb55.com", comment: "Placeholder example text for identifier used for nostr addresses."), text: $nip05) .autocorrectionDisabled(true) .textInputAutocapitalization(.never) .onReceive(Just(nip05)) { newValue in self.nip05 = newValue.trimmingCharacters(in: .whitespaces) } }, header: { - Text("NIP-05 Verification", comment: "Label for NIP-05 Verification section of user profile form.") + Text("Nostr Address", comment: "Label for the Nostr Address section of user profile form.") }, footer: { - if let parts = nip05_parts { - Text("'\(parts.username)' at '\(parts.host)' will be used for verification", comment: "Description of how the nip05 identifier would be used for verification.") - } else if !nip05.isEmpty { - Text("'\(nip05)' is an invalid NIP-05 identifier. It should look like an email.", comment: "Description of why the nip05 identifier is invalid.") - } else { - Text("") // without this, the keyboard dismisses unnecessarily when the footer changes state + switch validate_nostr_address(nip05: nip05_parts, nip05_str: nip05) { + case .empty: + // without this, the keyboard dismisses unnecessarily when the footer changes state + Text("") + case .valid: + Text("") + case .invalid: + Text("'\(nip05)' is an invalid nostr address. It should look like an email address.", comment: "Description of why the nostr address is invalid.") } }) @@ -211,3 +213,23 @@ struct EditMetadataView_Previews: PreviewProvider { EditMetadataView(damus_state: test_damus_state()) } } + +enum NIP05ValidationResult { + case empty + case invalid + case valid +} + +func validate_nostr_address(nip05: NIP05?, nip05_str: String) -> NIP05ValidationResult { + guard let nip05 else { + // couldn't parse + if nip05_str.isEmpty { + return .empty + } else { + return .invalid + } + } + + // could parse so we valid. + return .valid +}