Adding option to copy the private key from the repository

This commit is contained in:
Alexander Heinrich
2022-06-01 09:18:39 +02:00
parent 9829d6ceb4
commit 6b3196e798

View File

@@ -98,6 +98,8 @@ struct AccessoryListEntry: View {
}
Divider()
Button("Mark as \(accessory.isDeployed ? "deployable" : "deployed")", action: { accessory.isDeployed.toggle() })
Button("Copy private Key B64", action: { copyPrivateKey(accessory: accessory) })
}
}
@@ -188,6 +190,15 @@ struct AccessoryListEntry: View {
assert(false)
}
}
func copyPrivateKey(accessory: Accessory) {
let privateKey = accessory.privateKey
let keyB64 = privateKey.base64EncodedString()
let pasteboard = NSPasteboard.general
pasteboard.prepareForNewContents(with: .currentHostOnly)
pasteboard.setString(keyB64, forType: .string)
}
struct AccessoryListEntry_Previews: PreviewProvider {
@StateObject static var accessory = PreviewData.accessories.first!