diff --git a/Package.resolved b/Package.resolved index 30d2888..cfaa583 100644 --- a/Package.resolved +++ b/Package.resolved @@ -59,8 +59,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/Web3Auth/session-manager-swift.git", "state" : { - "revision" : "90afccc0e5e2ea8d671cdacb26899f60740b4e0b", - "version" : "6.0.0" + "revision" : "d86cd2a7f6d8095531ed609c728d851820fe85be", + "version" : "6.0.1" } }, { diff --git a/SingleFactorAuth.podspec b/SingleFactorAuth.podspec index b8c85c7..9a41e28 100644 --- a/SingleFactorAuth.podspec +++ b/SingleFactorAuth.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = "SingleFactorAuth" - spec.version = "9.0.1" + spec.version = "9.0.2" spec.ios.deployment_target = "14.0" spec.summary = "Enable one key flow for Web3Auth" spec.homepage = "https://github.com/Web3Auth/single-factor-auth-swift" diff --git a/Sources/SingleFactorAuth/SingleFactorAuth.swift b/Sources/SingleFactorAuth/SingleFactorAuth.swift index ae951f5..ab0cb00 100644 --- a/Sources/SingleFactorAuth/SingleFactorAuth.swift +++ b/Sources/SingleFactorAuth/SingleFactorAuth.swift @@ -28,12 +28,21 @@ public class SingleFactorAuth { if savedSessionId != nil && !savedSessionId!.isEmpty { sessionManager.setSessionId(sessionId: savedSessionId!) + // TODO: FIXME!!! Underlying dependency must use codable as a return type and not [String: Any] since it makes life difficult for ourselves unnecessarily let data = try await sessionManager.authorizeSession(origin: Bundle.main.bundleIdentifier ?? "single-factor-auth-swift") guard let privKey = data["privateKey"] as? String, let publicAddress = data["publicAddress"] as? String, let userInfo = data["userInfo"], let signatures = data["signatures"] else { throw SessionManagerError.decodingError } - state = SessionData(privateKey: privKey, publicAddress: publicAddress, signatures: signatures as? TorusKey.SessionData, userInfo: userInfo as? UserInfo) + + let jsonInfo = try JSONSerialization.data(withJSONObject: userInfo, options: []) + + let finalUserInfo = try JSONDecoder().decode(UserInfo.self, from: jsonInfo) + + let jsonData = try JSONSerialization.data(withJSONObject: signatures, options: []) + + let finalSignatures = try JSONDecoder().decode(TorusKey.SessionData.self, from: jsonData) + state = SessionData(privateKey: privKey, publicAddress: publicAddress, signatures: finalSignatures, userInfo: finalUserInfo) } }