better implementation
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import ExpoModulesCore
|
||||
import JOSESwift
|
||||
|
||||
struct JWK : Record {
|
||||
@Field
|
||||
@@ -25,6 +26,17 @@ struct JWK : Record {
|
||||
func toField() -> Field<JWK> {
|
||||
return Field(wrappedValue: self)
|
||||
}
|
||||
|
||||
func toSecKey() throws -> SecKey? {
|
||||
let jsonData = try JSONSerialization.data(withJSONObject: self.toDictionary())
|
||||
guard let jwk = try? JSONDecoder().decode(ECPrivateKey.self, from: jsonData),
|
||||
let key = try? jwk.converted(to: SecKey.self)
|
||||
else {
|
||||
print("Error creating SecKey.")
|
||||
return nil
|
||||
}
|
||||
return key
|
||||
}
|
||||
}
|
||||
|
||||
struct JWKPair : Record {
|
||||
|
||||
Reference in New Issue
Block a user