From 6b3196e798789222d1f3b6b20412dfadd973729d Mon Sep 17 00:00:00 2001 From: Alexander Heinrich Date: Wed, 1 Jun 2022 09:18:39 +0200 Subject: [PATCH] Adding option to copy the private key from the repository --- .../HaystackApp/Views/AccessoryListEntry.swift | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/OpenHaystack/OpenHaystack/HaystackApp/Views/AccessoryListEntry.swift b/OpenHaystack/OpenHaystack/HaystackApp/Views/AccessoryListEntry.swift index c90699e..69909f5 100644 --- a/OpenHaystack/OpenHaystack/HaystackApp/Views/AccessoryListEntry.swift +++ b/OpenHaystack/OpenHaystack/HaystackApp/Views/AccessoryListEntry.swift @@ -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!