mirror of
https://github.com/neon443/ShhShell.git
synced 2026-03-11 13:26:16 +00:00
added importkey to import keys and save to keychain added a picker to select a key id in connection view fix publickey and opensshpublickey returning a pubkey when privatekey is empty added generate key button and import button change HostManager.makeLabel() to a computed property on Host
50 lines
1.1 KiB
Swift
50 lines
1.1 KiB
Swift
//
|
|
// KeyImporterView.swift
|
|
// ShhShell
|
|
//
|
|
// Created by neon443 on 01/07/2025.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct KeyImporterView: View {
|
|
@ObservedObject var keyManager: KeyManager
|
|
|
|
@Environment(\.dismiss) var dismiss
|
|
|
|
@State var keyName: String = UIDevice().model + " " + Date().formatted()
|
|
@State var privkeyStr: String = ""
|
|
@State var keyType: KeyType = .ed25519
|
|
|
|
var keypair: Keypair {
|
|
Keypair(type: keyType, name: keyName, privateKey: privkeyStr.data(using: .utf8) ?? Data())
|
|
}
|
|
|
|
var body: some View {
|
|
List {
|
|
TextBox(label: "Name", text: $keyName, prompt: "A name for your key")
|
|
HStack {
|
|
Text("Private Key")
|
|
Spacer()
|
|
Text("Required")
|
|
.foregroundStyle(.red)
|
|
}
|
|
TextEditor(text: $privkeyStr)
|
|
|
|
TextEditor(text: .constant(keypair.openSshPubkey))
|
|
|
|
Button() {
|
|
keyManager.importKey(type: keyType, priv: privkeyStr, name: keyName)
|
|
dismiss()
|
|
} label: {
|
|
Label("Import", systemImage: "key.horizontal")
|
|
}
|
|
.buttonStyle(.borderedProminent)
|
|
}
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
KeyImporterView(keyManager: KeyManager())
|
|
}
|