diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index dfaa5ad..9325125 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1,24 +1,22 @@ PODS: - - AnyCodable-FlightSchool (0.6.7) - BigInt (5.2.0) - curvelib.swift (1.0.1) - Flutter (1.0.0) - KeychainSwift (20.0.0) - single_factor_auth_flutter (0.0.1): - Flutter - - SingleFactorAuth (= 6.0.0) - - SingleFactorAuth (6.0.0): + - SingleFactorAuth (= 8.0.0) + - SingleFactorAuth (8.0.0): - curvelib.swift (~> 1.0.1) - - Torus-fetchNodeDetails (~> 6.0.1) - - Torus-utils (~> 8.1.0) - - TorusSessionManager (~> 4.0.2) + - Torus-fetchNodeDetails (~> 6.0.3) + - Torus-utils (~> 9.0.1) + - TorusSessionManager (~> 5.0.0) - Torus-fetchNodeDetails (6.0.3): - BigInt (~> 5.2.0) - - Torus-utils (8.1.0): - - AnyCodable-FlightSchool (~> 0.6.0) + - Torus-utils (9.0.1): - curvelib.swift (~> 1.0.1) - - Torus-fetchNodeDetails (~> 6.0.1) - - TorusSessionManager (4.0.2): + - Torus-fetchNodeDetails (~> 6.0.3) + - TorusSessionManager (5.0.0): - curvelib.swift (~> 1.0.1) - KeychainSwift (~> 20.0.0) @@ -28,7 +26,6 @@ DEPENDENCIES: SPEC REPOS: trunk: - - AnyCodable-FlightSchool - BigInt - curvelib.swift - KeychainSwift @@ -44,17 +41,16 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/single_factor_auth_flutter/ios" SPEC CHECKSUMS: - AnyCodable-FlightSchool: 261cbe76757802b17d471b9059b21e6fa5edf57b BigInt: f668a80089607f521586bbe29513d708491ef2f7 curvelib.swift: d0746ae82bee34016c06da3567a97e493b3c979f Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 KeychainSwift: 0ce6a4d13f7228054d1a71bb1b500448fb2ab837 - single_factor_auth_flutter: c15c7a7a225399326d38c85de60ba3e1d5c5f82a - SingleFactorAuth: 2c25b70f7faac954fc15fe8f9598f80b09ca450e + single_factor_auth_flutter: 9617e5ffce9c0251bddb19cbe49293f921c13b79 + SingleFactorAuth: 2bfa8ad0fe8d0023fffdf1a5f0c9634ca3ee66d8 Torus-fetchNodeDetails: 6c349f47cbca36a4b3f276fe26d03c1b39b20949 - Torus-utils: 3ec4dba5ea50935ab129077adef4207af5a00225 - TorusSessionManager: 05a1a8f3265d0949a1a342c4ba2c52882445b614 + Torus-utils: 1d23e6eedf9ee7df9ecc2605b765ad68eb194f71 + TorusSessionManager: 42c21f100d895976fabe3806cb9c575392f6e424 PODFILE CHECKSUM: d5c402b2f74646de5c7f24c1231886362b49b38f -COCOAPODS: 1.14.3 +COCOAPODS: 1.14.2 diff --git a/example/ios/Runner/AppDelegate.swift b/example/ios/Runner/AppDelegate.swift index 70693e4..b636303 100644 --- a/example/ios/Runner/AppDelegate.swift +++ b/example/ios/Runner/AppDelegate.swift @@ -1,7 +1,7 @@ import UIKit import Flutter -@UIApplicationMain +@main @objc class AppDelegate: FlutterAppDelegate { override func application( _ application: UIApplication, diff --git a/ios/Classes/SingleFactorAuthFlutterPlugin.swift b/ios/Classes/SingleFactorAuthFlutterPlugin.swift index 5ccd2f6..eaf6f2d 100644 --- a/ios/Classes/SingleFactorAuthFlutterPlugin.swift +++ b/ios/Classes/SingleFactorAuthFlutterPlugin.swift @@ -16,21 +16,25 @@ public class SingleFactorAuthFlutterPlugin: NSObject, FlutterPlugin { private func getNetwork(_ network: String) -> Web3AuthNetwork { switch network { case "mainnet": - return Web3AuthNetwork.MAINNET + return .legacy(.MAINNET) case "testnet": - return Web3AuthNetwork.TESTNET + return .legacy(.TESTNET) case "aqua": - return Web3AuthNetwork.AQUA + return .legacy(.AQUA) case "cyan": - return Web3AuthNetwork.CYAN + return .legacy(.CYAN) + case "sappire_devnet": + return .sapphire(.SAPPHIRE_DEVNET) + case "sapphire_mainnet": + return .sapphire(.SAPPHIRE_MAINNET) default: - return Web3AuthNetwork.MAINNET + return .sapphire(.SAPPHIRE_MAINNET) } } var decoder = JSONDecoder() var encoder = JSONEncoder() - var singleFactorAuthArgs: SingleFactorAuthArgs? + var sfaParams: SFAParams? var singleFactorAuth: SingleFactorAuth? public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { @@ -47,13 +51,14 @@ public class SingleFactorAuthFlutterPlugin: NSObject, FlutterPlugin { let params = try self.decoder.decode(InitParams.self, from: data) - singleFactorAuthArgs = SingleFactorAuthArgs( - web3AuthClientId: params.clientid, - network: self.getNetwork(params.network) + sfaParams = SFAParams( + web3AuthClientId: params.clientId, + network: self.getNetwork(params.network), + sessionTime: params.sessionTime ?? 86400 ) - let singleFactorAuth = SingleFactorAuth( - singleFactorAuthArgs: singleFactorAuthArgs! + let singleFactorAuth = try SingleFactorAuth( + params: sfaParams! ) self.singleFactorAuth = singleFactorAuth @@ -72,59 +77,38 @@ public class SingleFactorAuthFlutterPlugin: NSObject, FlutterPlugin { result(throwKeyNotGeneratedError()) } - case "getTorusKey": + case "connect": let args = call.arguments as? String guard let data = args?.data(using: .utf8) else { return result(throwKeyNotGeneratedError()) } let params = try self.decoder.decode(getTorusKeyParams.self, from: data) - - let loginParams = LoginParams( - verifier: params.verifier, - verifierId: params.verifierId, - idToken: params.idToken - ) - - do { - - let torusKeyCF = try await singleFactorAuth?.getKey( - loginParams: loginParams + + let loginParams: LoginParams + if params.aggregateVerifier?.isEmpty ?? true { + loginParams = LoginParams( + verifier: params.verifier, + verifierId: params.verifierId, + idToken: params.idToken + ) + } else { + loginParams = LoginParams( + verifier: params.aggregateVerifier!, + verifierId: params.verifierId, + idToken: params.idToken, + subVerifierInfoArray: [ + TorusSubVerifierInfo( + verifier: params.verifier, + idToken: params.idToken + ) + ] ) - - let resultData = try encoder.encode(torusKeyCF) - let resultJson = String(decoding: resultData, as: UTF8.self) - return result(resultJson) - } catch { - result(throwKeyNotGeneratedError()) - } - break - - case "getAggregateTorusKey": - let args = call.arguments as? String - guard let data = args?.data(using: .utf8) else { - return result(throwKeyNotGeneratedError()) - } - - let params = try self.decoder.decode(getTorusKeyParams.self, from: data) - - guard let aggregateVerifier = params.aggregateVerifier else { - return result(throwParamMissingError(param: "aggregateVerifier")) } - let loginParams = LoginParams( - verifier: params.aggregateVerifier!, - verifierId: params.verifierId, - idToken: params.idToken, - subVerifierInfoArray: [ - TorusSubVerifierInfo( - verifier: params.verifier, - idToken: params.idToken - ) - ]) - do { - let torusKeyCF = try await singleFactorAuth?.getKey( + + let torusKeyCF = try await singleFactorAuth?.connect( loginParams: loginParams ) @@ -135,6 +119,15 @@ public class SingleFactorAuthFlutterPlugin: NSObject, FlutterPlugin { result(throwKeyNotGeneratedError()) } break + + case "isSessionIdExists": + if(singleFactorAuth == nil) { + return result(false) + } else { + return result(try await singleFactorAuth?.isSessionIdExists()) + } + break + default: break } @@ -157,7 +150,8 @@ public class SingleFactorAuthFlutterPlugin: NSObject, FlutterPlugin { struct InitParams: Codable { var network: String - var clientid: String + var clientId: String + var sessionTime: Int? = 86400 } struct getTorusKeyParams: Codable { diff --git a/ios/single_factor_auth_flutter.podspec b/ios/single_factor_auth_flutter.podspec index b441109..0fddef6 100644 --- a/ios/single_factor_auth_flutter.podspec +++ b/ios/single_factor_auth_flutter.podspec @@ -15,7 +15,7 @@ A new Flutter plugin project. s.source = { :path => '.' } s.source_files = 'Classes/**/*' s.dependency 'Flutter' - s.dependency 'SingleFactorAuth', '6.0.0' + s.dependency 'SingleFactorAuth', '8.0.0' s.platform = :ios, '14.0' # Flutter.framework does not contain a i386 slice.