iOS: create and manage setup links like the web interface

Add peer and Issue new config offer the same choice as the web UI: show
the config now or send a one-time setup link (1 h, 24 h or 7 d, PIN on by
default). The link sheet shares the link through the iOS share sheet and
shows the PIN, expiry and a QR code of the link. The peer page gets a
setup link card with share, copy and revoke.
This commit is contained in:
Daniel Redetzke
2026-10-03 23:29:28 +03:00
parent e47e984c1d
commit 820c2448f8
8 changed files with 385 additions and 41 deletions
+47
View File
@@ -145,6 +145,53 @@ nonisolated struct IssuedConfig: Decodable, Identifiable {
var id: String { peer.id + peer.publicKey }
}
/// A setup link for the admin to send. It sets up a device once.
nonisolated struct SetupSecret: Decodable, Hashable {
let url: String
let path: String
let pin: String?
let expires: Date
let qr: String
}
/// The answer to creating a peer or issuing a config with a setup link.
nonisolated struct LinkCreated: Decodable {
let peer: Peer
let setup: SetupSecret
let applyError: String
}
/// A config shown now, or a setup link to send.
enum IssueOutcome: Identifiable {
case config(IssuedConfig)
case link(LinkCreated)
var id: String {
switch self {
case .config(let c): c.id
case .link(let l): l.setup.path
}
}
var peer: Peer {
switch self {
case .config(let c): c.peer
case .link(let l): l.peer
}
}
var applyError: String {
switch self {
case .config(let c): c.applyError
case .link(let l): l.applyError
}
}
}
nonisolated struct PeerOnly: Decodable {
let peer: Peer
}
nonisolated struct ClientDefaults: Codable, Equatable {
var dns: [String]
var allowedIPs: [String]