better implementation

This commit is contained in:
Hailey
2024-04-14 23:27:27 -07:00
parent 71f1e44653
commit 2ada0cbd0d
12 changed files with 136 additions and 62 deletions
@@ -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 {