Skip to content

Commit 6b3196e

Browse files
committed
Adding option to copy the private key from the repository
1 parent 9829d6c commit 6b3196e

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

OpenHaystack/OpenHaystack/HaystackApp/Views/AccessoryListEntry.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ struct AccessoryListEntry: View {
9898
}
9999
Divider()
100100
Button("Mark as \(accessory.isDeployed ? "deployable" : "deployed")", action: { accessory.isDeployed.toggle() })
101+
102+
Button("Copy private Key B64", action: { copyPrivateKey(accessory: accessory) })
101103
}
102104
}
103105

@@ -188,6 +190,15 @@ struct AccessoryListEntry: View {
188190
assert(false)
189191
}
190192
}
193+
194+
func copyPrivateKey(accessory: Accessory) {
195+
let privateKey = accessory.privateKey
196+
let keyB64 = privateKey.base64EncodedString()
197+
198+
let pasteboard = NSPasteboard.general
199+
pasteboard.prepareForNewContents(with: .currentHostOnly)
200+
pasteboard.setString(keyB64, forType: .string)
201+
}
191202

192203
struct AccessoryListEntry_Previews: PreviewProvider {
193204
@StateObject static var accessory = PreviewData.accessories.first!

0 commit comments

Comments
 (0)