nip42: add initial relay auth support
Lightning-Invoice: lnbc1pjcpaakpp5gjs4f626hf8w6slx84xz3wwhlf309z503rjutckdxv6wwg5ldavsdqqcqzpgxqrrs0fppqjaxxw43p7em4g59vedv7pzl76kt0qyjfsp5qcp9de7a7t8h6zs5mcssfaqp4exrnkehqtg2hf0ary3z5cjnasvs9qyyssq55523e4h3cazhkv7f8jqf5qp0n8spykls49crsu5t3m636u3yj4qdqjkdl2nxf6jet5t2r2pfrxmm8rjpqjd3ylrzqq89m4gqt5l6ycqf92c7h Closes: https://github.com/damus-io/damus/issues/940 Signed-off-by: Charlie Fish <contact@charlie.fish> Signed-off-by: William Casarin <jb55@jb55.com> Changelog-Added: Add NIP-42 relay auth support
This commit is contained in:
committed by
William Casarin
parent
4c37bfc128
commit
84cfeb1604
@@ -97,6 +97,9 @@ class SuggestedUsersViewModel: ObservableObject {
|
||||
|
||||
case .ok:
|
||||
break
|
||||
|
||||
case .auth:
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
35
damus/Views/Relays/Detail/RelayAuthenticationDetail.swift
Normal file
35
damus/Views/Relays/Detail/RelayAuthenticationDetail.swift
Normal file
@@ -0,0 +1,35 @@
|
||||
//
|
||||
// RelayAuthenticationDetail.swift
|
||||
// damus
|
||||
//
|
||||
// Created by Charlie Fish on 12/18/23.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct RelayAuthenticationDetail: View {
|
||||
let state: RelayAuthenticationState
|
||||
|
||||
var body: some View {
|
||||
switch state {
|
||||
case .none:
|
||||
EmptyView()
|
||||
case .pending:
|
||||
Text(NSLocalizedString("Pending", comment: "Label to display that authentication to a server is pending."))
|
||||
case .verified:
|
||||
Text(NSLocalizedString("Authenticated", comment: "Label to display that authentication to a server has succeeded."))
|
||||
.foregroundStyle(DamusColors.success)
|
||||
case .error:
|
||||
Text(NSLocalizedString("Error", comment: "Label to display that authentication to a server has failed."))
|
||||
.foregroundStyle(DamusColors.danger)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct RelayAuthenticationDetail_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
RelayAuthenticationDetail(state: .none)
|
||||
RelayAuthenticationDetail(state: .pending)
|
||||
RelayAuthenticationDetail(state: .verified)
|
||||
}
|
||||
}
|
||||
@@ -92,7 +92,14 @@ struct RelayDetailView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if let authentication_state: RelayAuthenticationState = relay_object?.authentication_state,
|
||||
authentication_state != .none {
|
||||
Section(NSLocalizedString("Authentication", comment: "Header label to display authentication details for a given relay.")) {
|
||||
RelayAuthenticationDetail(state: authentication_state)
|
||||
}
|
||||
}
|
||||
|
||||
if let pubkey = nip11?.pubkey {
|
||||
Section(NSLocalizedString("Admin", comment: "Label to display relay contact user.")) {
|
||||
UserViewRow(damus_state: state, pubkey: pubkey)
|
||||
@@ -175,9 +182,13 @@ struct RelayDetailView: View {
|
||||
}
|
||||
return attrString
|
||||
}
|
||||
|
||||
|
||||
private var relay_object: Relay? {
|
||||
state.pool.get_relay(relay)
|
||||
}
|
||||
|
||||
private var relay_connection: RelayConnection? {
|
||||
state.pool.get_relay(relay)?.connection
|
||||
relay_object?.connection
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -165,6 +165,8 @@ struct SaveKeysView: View {
|
||||
break
|
||||
case .ok:
|
||||
break
|
||||
case .auth:
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user