diff --git a/android/build.gradle b/android/build.gradle index e5c3bc4..67025aa 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -49,7 +49,7 @@ android { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4' - implementation 'com.github.Web3Auth:single-factor-auth-android:0.0.6' - implementation 'org.torusresearch:fetch-node-details-java:3.1.0' + implementation 'com.github.Web3Auth:single-factor-auth-android:0.2.0' + implementation 'org.torusresearch:fetch-node-details-java:3.3.0' implementation 'com.google.code.gson:gson:2.9.1' } diff --git a/android/src/main/kotlin/com/web3auth/single_factor_auth_flutter/SFAParams.kt b/android/src/main/kotlin/com/web3auth/single_factor_auth_flutter/SFAParams.kt new file mode 100644 index 0000000..134188e --- /dev/null +++ b/android/src/main/kotlin/com/web3auth/single_factor_auth_flutter/SFAParams.kt @@ -0,0 +1,3 @@ +package com.web3auth.single_factor_auth_flutter + +data class SFAParams(val network: String, var clientid: String) \ No newline at end of file diff --git a/android/src/main/kotlin/com/web3auth/single_factor_auth_flutter/SingleFactorAuthFlutterPlugin.kt b/android/src/main/kotlin/com/web3auth/single_factor_auth_flutter/SingleFactorAuthFlutterPlugin.kt index 94c80ce..3137511 100644 --- a/android/src/main/kotlin/com/web3auth/single_factor_auth_flutter/SingleFactorAuthFlutterPlugin.kt +++ b/android/src/main/kotlin/com/web3auth/single_factor_auth_flutter/SingleFactorAuthFlutterPlugin.kt @@ -47,6 +47,7 @@ class SingleFactorAuthFlutterPlugin : FlutterPlugin, MethodCallHandler { "testnet" -> TorusNetwork.TESTNET "aqua" -> TorusNetwork.AQUA "cyan" -> TorusNetwork.CYAN + "celeste" -> TorusNetwork.CELESTE else -> TorusNetwork.MAINNET } } @@ -72,8 +73,8 @@ class SingleFactorAuthFlutterPlugin : FlutterPlugin, MethodCallHandler { "init" -> { val initArgs = call.arguments() - val params = gson.fromJson(initArgs, Web3AuthNetwork::class.java) - singleFactorAuthArgs = SingleFactorAuthArgs(getNetwork(params.network)) + val params = gson.fromJson(initArgs, SFAParams::class.java) + singleFactorAuthArgs = SingleFactorAuthArgs(getNetwork(params.network), params.clientid) singleFactorAuth = SingleFactorAuth(singleFactorAuthArgs) return null } diff --git a/android/src/main/kotlin/com/web3auth/single_factor_auth_flutter/Web3AuthNetwork.kt b/android/src/main/kotlin/com/web3auth/single_factor_auth_flutter/Web3AuthNetwork.kt deleted file mode 100644 index 6bf3336..0000000 --- a/android/src/main/kotlin/com/web3auth/single_factor_auth_flutter/Web3AuthNetwork.kt +++ /dev/null @@ -1,3 +0,0 @@ -package com.web3auth.single_factor_auth_flutter - -data class Web3AuthNetwork(val network: String) \ No newline at end of file diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 944467e..5deb3e3 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1,31 +1,26 @@ PODS: - - BigInt (5.0.0) - - CryptoSwift (1.5.1) + - AnyCodable-FlightSchool (0.6.7) + - BigInt (5.2.0) + - curvelib.swift (1.0.1) - Flutter (1.0.0) - - GenericJSON (2.0.2) - KeychainSwift (20.0.0) - - secp256k1.swift (0.1.4) - single_factor_auth_flutter (0.0.1): - Flutter - - SingleFactorAuth (~> 2.0.3) - - SingleFactorAuth (2.0.3): - - Torus-fetchNodeDetails (~> 4.0.1) - - Torus-utils (~> 5.0.0) - - TorusSessionManager (~> 2.0.0) - - Torus-fetchNodeDetails (4.0.1): - - web3.swift (~> 0.9.3) - - Torus-utils (5.0.0): - - CryptoSwift (~> 1.5.1) - - secp256k1.swift (~> 0.1.4) - - Torus-fetchNodeDetails (~> 4.0.0) - - TorusSessionManager (2.0.0): - - CryptoSwift (~> 1.5.1) + - SingleFactorAuth (~> 5.0.0) + - SingleFactorAuth (5.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): + - BigInt (~> 5.2.0) + - Torus-utils (8.1.0): + - AnyCodable-FlightSchool (~> 0.6.0) + - curvelib.swift (~> 1.0.1) + - Torus-fetchNodeDetails (~> 6.0.1) + - TorusSessionManager (4.0.2): + - curvelib.swift (~> 1.0.1) - KeychainSwift (~> 20.0.0) - - web3.swift (~> 0.9.3) - - web3.swift (0.9.3): - - BigInt (~> 5.0.0) - - GenericJSON (~> 2.0) - - secp256k1.swift (~> 0.1) DEPENDENCIES: - Flutter (from `Flutter`) @@ -33,16 +28,14 @@ DEPENDENCIES: SPEC REPOS: trunk: + - AnyCodable-FlightSchool - BigInt - - CryptoSwift - - GenericJSON + - curvelib.swift - KeychainSwift - - secp256k1.swift - SingleFactorAuth - Torus-fetchNodeDetails - Torus-utils - TorusSessionManager - - web3.swift EXTERNAL SOURCES: Flutter: @@ -51,19 +44,17 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/single_factor_auth_flutter/ios" SPEC CHECKSUMS: - BigInt: 74b4d88367b0e819d9f77393549226d36faeb0d8 - CryptoSwift: c4f2debceb38bf44c80659afe009f71e23e4a082 + AnyCodable-FlightSchool: 261cbe76757802b17d471b9059b21e6fa5edf57b + BigInt: f668a80089607f521586bbe29513d708491ef2f7 + curvelib.swift: d0746ae82bee34016c06da3567a97e493b3c979f Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 - GenericJSON: 79a840eeb77030962e8cf02a62d36bd413b67626 KeychainSwift: 0ce6a4d13f7228054d1a71bb1b500448fb2ab837 - secp256k1.swift: a7e7a214f6db6ce5db32cc6b2b45e5c4dd633634 - single_factor_auth_flutter: dc31ec16f89101af2d7be3a0f4f807889dc96726 - SingleFactorAuth: 9aa82543902e2a4de5a0a456a294eed5d3816d9d - Torus-fetchNodeDetails: a92d02f1bfe91bd61c90f92d64df023babaa5bfa - Torus-utils: 9ac46eb76935e328a6628108c94b66e1af1e7fa7 - TorusSessionManager: dcd47b52067fe32a8289f970580299783d58e286 - web3.swift: c6c3bf1f853743f8a7a58d263e5f7e46545e22c7 + single_factor_auth_flutter: 32a02b25ceb8405f3cedce4b675cfb906b8cb099 + SingleFactorAuth: ee61a0969705e016871d0fb1fa65dd4a22e08316 + Torus-fetchNodeDetails: 6c349f47cbca36a4b3f276fe26d03c1b39b20949 + Torus-utils: 3ec4dba5ea50935ab129077adef4207af5a00225 + TorusSessionManager: 05a1a8f3265d0949a1a342c4ba2c52882445b614 PODFILE CHECKSUM: d5c402b2f74646de5c7f24c1231886362b49b38f -COCOAPODS: 1.14.3 +COCOAPODS: 1.14.2 diff --git a/example/lib/main.dart b/example/lib/main.dart index 697070a..572d3aa 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -6,6 +6,7 @@ import 'package:flutter/material.dart'; import 'package:single_factor_auth_flutter/input.dart'; import 'package:single_factor_auth_flutter/output.dart'; import 'package:single_factor_auth_flutter/single_factor_auth_flutter.dart'; + import './utils.dart'; void main() { @@ -23,7 +24,7 @@ class _MyAppState extends State { final _singleFactorAuthFlutterPlugin = SingleFactAuthFlutter(); String _result = ''; bool logoutVisible = false; - TorusNetwork torusNetwork = TorusNetwork.testnet; + Web3AuthNetwork torusNetwork = Web3AuthNetwork.aqua; @override void initState() { @@ -43,7 +44,7 @@ class _MyAppState extends State { Future init() async { await _singleFactorAuthFlutterPlugin - .init(Web3AuthNetwork(network: torusNetwork)); + .init(SFAParams(network: torusNetwork, clientid: 'YOUR_CLIENT_ID')); } Future initialize() async { diff --git a/ios/Classes/SingleFactorAuthFlutterPlugin.swift b/ios/Classes/SingleFactorAuthFlutterPlugin.swift index f60c546..5ccd2f6 100644 --- a/ios/Classes/SingleFactorAuthFlutterPlugin.swift +++ b/ios/Classes/SingleFactorAuthFlutterPlugin.swift @@ -13,18 +13,18 @@ public class SingleFactorAuthFlutterPlugin: NSObject, FlutterPlugin { registrar.addMethodCallDelegate(instance, channel: channel) } - private func getNetwork(_ network: String) -> TorusNetwork { + private func getNetwork(_ network: String) -> Web3AuthNetwork { switch network { case "mainnet": - return TorusNetwork.MAINNET + return Web3AuthNetwork.MAINNET case "testnet": - return TorusNetwork.TESTNET + return Web3AuthNetwork.TESTNET case "aqua": - return TorusNetwork.AQUA + return Web3AuthNetwork.AQUA case "cyan": - return TorusNetwork.CYAN + return Web3AuthNetwork.CYAN default: - return TorusNetwork.MAINNET + return Web3AuthNetwork.MAINNET } } @@ -48,6 +48,7 @@ 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) ) @@ -60,7 +61,7 @@ public class SingleFactorAuthFlutterPlugin: NSObject, FlutterPlugin { case "initialize": do { - guard let torusKeyCF = await singleFactorAuth?.initialize() else { + guard let torusKeyCF = try await singleFactorAuth?.initialize() else { return result(nil) } @@ -156,6 +157,7 @@ public class SingleFactorAuthFlutterPlugin: NSObject, FlutterPlugin { struct InitParams: Codable { var network: String + var clientid: String } struct getTorusKeyParams: Codable { diff --git a/ios/single_factor_auth_flutter.podspec b/ios/single_factor_auth_flutter.podspec index 850ba5a..2305028 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', '~> 2.0.3' + s.dependency 'SingleFactorAuth', '~> 5.0.0' s.platform = :ios, '14.0' # Flutter.framework does not contain a i386 slice. diff --git a/lib/input.dart b/lib/input.dart index 1b4d6c8..851735f 100644 --- a/lib/input.dart +++ b/lib/input.dart @@ -21,19 +21,21 @@ class LoginParams { } } -class Web3AuthNetwork { - final TorusNetwork network; +class SFAParams { + final Web3AuthNetwork network; + final String clientid; - Web3AuthNetwork({required this.network}); + SFAParams({required this.network, required this.clientid}); Map toJson() { return { 'network': network.name, + 'clientid': clientid, }; } } -enum TorusNetwork { mainnet, testnet, cyan, aqua } +enum Web3AuthNetwork { mainnet, testnet, cyan, aqua, celeste } class UserCancelledException implements Exception {} diff --git a/lib/single_factor_auth_flutter.dart b/lib/single_factor_auth_flutter.dart index e8d4022..d333511 100644 --- a/lib/single_factor_auth_flutter.dart +++ b/lib/single_factor_auth_flutter.dart @@ -15,7 +15,7 @@ class SingleFactAuthFlutter { return SingleFactAuthFlutterPlatform.instance.getPlatformVersion(); } - Future init(Web3AuthNetwork initParams) async { + Future init(SFAParams initParams) async { Map initParamsJson = initParams.toJson(); initParamsJson.removeWhere((key, value) => value == null); await _channel.invokeMethod('init', jsonEncode(initParamsJson));