2020-02-19 04:52:00 +00:00
|
|
|
import Foundation
|
|
|
|
import SecretKit
|
|
|
|
|
|
|
|
enum Preview {}
|
|
|
|
|
|
|
|
extension Preview {
|
|
|
|
|
|
|
|
struct Secret: SecretKit.Secret {
|
|
|
|
|
|
|
|
let id = UUID().uuidString
|
2020-03-04 07:14:38 +00:00
|
|
|
let name: String
|
2020-03-09 05:17:59 +00:00
|
|
|
let algorithm = Algorithm.ellipticCurve
|
|
|
|
let keySize = 256
|
2020-03-04 07:14:38 +00:00
|
|
|
let publicKey = UUID().uuidString.data(using: .utf8)!
|
2020-02-19 04:52:00 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
extension Preview {
|
|
|
|
|
|
|
|
class Store: SecretStore, ObservableObject {
|
|
|
|
|
2020-03-07 23:42:40 +00:00
|
|
|
let isAvailable = true
|
2020-03-09 03:03:40 +00:00
|
|
|
let id = UUID()
|
2020-03-04 07:14:38 +00:00
|
|
|
let name = "Preview Store"
|
2020-02-19 04:52:00 +00:00
|
|
|
@Published var secrets: [Secret] = []
|
|
|
|
|
|
|
|
init(secrets: [Secret]) {
|
|
|
|
self.secrets.append(contentsOf: secrets)
|
|
|
|
}
|
|
|
|
|
|
|
|
init(numberOfRandomSecrets: Int) {
|
2020-03-04 07:14:38 +00:00
|
|
|
let new = (0...numberOfRandomSecrets).map { Secret(name: String(describing: $0)) }
|
2020-02-19 04:52:00 +00:00
|
|
|
self.secrets.append(contentsOf: new)
|
|
|
|
}
|
|
|
|
|
2020-03-04 07:14:38 +00:00
|
|
|
func sign(data: Data, with secret: Preview.Secret) throws -> Data {
|
|
|
|
return data
|
|
|
|
}
|
|
|
|
|
|
|
|
func delete(secret: Preview.Secret) throws {
|
|
|
|
}
|
|
|
|
|
2020-02-19 04:52:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|