86979d0abc
apple / swift (push) Successful in 55s
ci / rust (push) Successful in 1m16s
ci / web (push) Successful in 33s
ci / docs-site (push) Successful in 29s
android / android (push) Successful in 3m18s
deb / build-publish (push) Successful in 3m7s
decky / build-publish (push) Successful in 12s
docker / build-push (--build-arg FEDORA_VERSION=44, ci, ci/fedora-rpm.Dockerfile, punktfunk-fedora44-rpm) (push) Successful in 4s
docker / build-push (., web/Dockerfile, punktfunk-web) (push) Successful in 4s
ci / bench (push) Successful in 4m32s
docker / build-push (ci, ci/fedora-rpm.Dockerfile, punktfunk-fedora-rpm) (push) Successful in 5s
docker / build-push (docs-site, docs-site/Dockerfile, punktfunk-docs) (push) Successful in 5s
docker / build-push (ci, ci/rust-ci.Dockerfile, punktfunk-rust-ci) (push) Successful in 5s
rpm / build-publish (bazzite, punktfunk-fedora-rpm) (push) Successful in 8m47s
rpm / build-publish (fedora-44, punktfunk-fedora44-rpm) (push) Successful in 8m50s
docker / deploy-docs (push) Successful in 35s
improve iOS & iPadOS UI
87 lines
3.7 KiB
Swift
87 lines
3.7 KiB
Swift
// Trust-on-first-use prompt: shown over the live-but-blurred stream when connecting to an
|
|
// unpinned host. The user compares the fingerprint with the one the host logged at startup,
|
|
// or drops this and runs the PIN pairing ceremony instead.
|
|
|
|
import Foundation
|
|
import SwiftUI
|
|
|
|
struct TrustCardView: View {
|
|
let fingerprint: Data
|
|
let hostName: String
|
|
let onCancel: () -> Void
|
|
let onTrust: () -> Void
|
|
let onPairInstead: () -> Void
|
|
|
|
var body: some View {
|
|
VStack(spacing: 14) {
|
|
Image(systemName: "lock.shield")
|
|
.font(.system(size: 36, weight: .light))
|
|
.foregroundStyle(.tint)
|
|
Text("Verify \(hostName)")
|
|
.font(.title3.weight(.semibold))
|
|
Text("First connection. Compare this fingerprint with the one "
|
|
+ "punktfunk-host logged at startup (\u{201C}clients pin this "
|
|
+ "fingerprint\u{201D}):")
|
|
.font(.callout)
|
|
.foregroundStyle(.secondary)
|
|
.multilineTextAlignment(.center)
|
|
Text(Self.format(fingerprint: fingerprint))
|
|
.font(.system(.callout, design: .monospaced))
|
|
#if !os(tvOS)
|
|
.textSelection(.enabled)
|
|
#endif
|
|
.padding(10)
|
|
.background(.quaternary, in: RoundedRectangle(cornerRadius: 8))
|
|
HStack(spacing: 12) {
|
|
Button("Cancel", role: .cancel, action: onCancel)
|
|
#if !os(tvOS)
|
|
.keyboardShortcut(.cancelAction)
|
|
#endif
|
|
Button("Trust & Connect", action: onTrust)
|
|
// Opaque prominent, NOT glass: this card is itself a glass panel
|
|
// (.glassBackground below), and glass-on-glass loses contrast — a tinted
|
|
// bordered button reads cleanly over glass (HIG). The sheet primaries stay
|
|
// glass because the system manages the sheet's own glass layering.
|
|
.buttonStyle(.borderedProminent)
|
|
#if !os(tvOS)
|
|
.keyboardShortcut(.defaultAction)
|
|
#endif
|
|
}
|
|
#if os(iOS)
|
|
.controlSize(.large)
|
|
#endif
|
|
// The verified alternative to eyeballing hex: drop this session (the host
|
|
// serves one connection at a time) and run the SPAKE2 PIN ceremony instead.
|
|
Button("Pair with PIN instead…", action: onPairInstead)
|
|
#if os(macOS)
|
|
.buttonStyle(.link)
|
|
#else
|
|
.buttonStyle(.borderless)
|
|
#endif
|
|
.font(.callout)
|
|
}
|
|
.padding(28)
|
|
.frame(maxWidth: 440)
|
|
// Floating trust card over the blurred stream — Liquid Glass on 26+, .regularMaterial
|
|
// fallback below. The inner fingerprint box stays .quaternary (content, not glass).
|
|
.glassBackground(RoundedRectangle(cornerRadius: 18))
|
|
}
|
|
|
|
/// 64 hex chars → four groups per line, two lines — easy to eyeball against the log.
|
|
private static func format(fingerprint: Data) -> String {
|
|
let hex = fingerprint.map { String(format: "%02x", $0) }.joined()
|
|
let groups = stride(from: 0, to: hex.count, by: 8).map { i -> String in
|
|
let start = hex.index(hex.startIndex, offsetBy: i)
|
|
let end = hex.index(start, offsetBy: min(8, hex.count - i))
|
|
return String(hex[start..<end])
|
|
}
|
|
return groups.chunks(of: 4).map { $0.joined(separator: " ") }.joined(separator: "\n")
|
|
}
|
|
}
|
|
|
|
private extension Array {
|
|
func chunks(of size: Int) -> [[Element]] {
|
|
stride(from: 0, to: count, by: size).map { Array(self[$0..<Swift.min($0 + size, count)]) }
|
|
}
|
|
}
|