Skip to content

Commit

Permalink
Merge pull request #7 from Web3Auth/feat/enable-gating
Browse files Browse the repository at this point in the history
feat: rename init params, update clientid and sfa-android deps
  • Loading branch information
chaitanyapotti authored Jul 9, 2024
2 parents 59b4ca4 + 8a4fb76 commit a15e537
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 59 deletions.
4 changes: 2 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.web3auth.single_factor_auth_flutter

data class SFAParams(val network: String, var clientid: String)
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class SingleFactorAuthFlutterPlugin : FlutterPlugin, MethodCallHandler {
"testnet" -> TorusNetwork.TESTNET
"aqua" -> TorusNetwork.AQUA
"cyan" -> TorusNetwork.CYAN
"celeste" -> TorusNetwork.CELESTE
else -> TorusNetwork.MAINNET
}
}
Expand All @@ -72,8 +73,8 @@ class SingleFactorAuthFlutterPlugin : FlutterPlugin, MethodCallHandler {

"init" -> {
val initArgs = call.arguments<String>()
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
}
Expand Down

This file was deleted.

65 changes: 28 additions & 37 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,48 +1,41 @@
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`)
- single_factor_auth_flutter (from `.symlinks/plugins/single_factor_auth_flutter/ios`)

SPEC REPOS:
trunk:
- AnyCodable-FlightSchool
- BigInt
- CryptoSwift
- GenericJSON
- curvelib.swift
- KeychainSwift
- secp256k1.swift
- SingleFactorAuth
- Torus-fetchNodeDetails
- Torus-utils
- TorusSessionManager
- web3.swift

EXTERNAL SOURCES:
Flutter:
Expand All @@ -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
5 changes: 3 additions & 2 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -23,7 +24,7 @@ class _MyAppState extends State<MyApp> {
final _singleFactorAuthFlutterPlugin = SingleFactAuthFlutter();
String _result = '';
bool logoutVisible = false;
TorusNetwork torusNetwork = TorusNetwork.testnet;
Web3AuthNetwork torusNetwork = Web3AuthNetwork.aqua;

@override
void initState() {
Expand All @@ -43,7 +44,7 @@ class _MyAppState extends State<MyApp> {

Future<void> init() async {
await _singleFactorAuthFlutterPlugin
.init(Web3AuthNetwork(network: torusNetwork));
.init(SFAParams(network: torusNetwork, clientid: 'YOUR_CLIENT_ID'));
}

Future<void> initialize() async {
Expand Down
16 changes: 9 additions & 7 deletions ios/Classes/SingleFactorAuthFlutterPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand All @@ -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)
)

Expand All @@ -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)
}

Expand Down Expand Up @@ -156,6 +157,7 @@ public class SingleFactorAuthFlutterPlugin: NSObject, FlutterPlugin {

struct InitParams: Codable {
var network: String
var clientid: String
}

struct getTorusKeyParams: Codable {
Expand Down
2 changes: 1 addition & 1 deletion ios/single_factor_auth_flutter.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 6 additions & 4 deletions lib/input.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, dynamic> toJson() {
return {
'network': network.name,
'clientid': clientid,
};
}
}

enum TorusNetwork { mainnet, testnet, cyan, aqua }
enum Web3AuthNetwork { mainnet, testnet, cyan, aqua, celeste }

class UserCancelledException implements Exception {}

Expand Down
2 changes: 1 addition & 1 deletion lib/single_factor_auth_flutter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class SingleFactAuthFlutter {
return SingleFactAuthFlutterPlatform.instance.getPlatformVersion();
}

Future<void> init(Web3AuthNetwork initParams) async {
Future<void> init(SFAParams initParams) async {
Map<String, dynamic> initParamsJson = initParams.toJson();
initParamsJson.removeWhere((key, value) => value == null);
await _channel.invokeMethod('init', jsonEncode(initParamsJson));
Expand Down

0 comments on commit a15e537

Please sign in to comment.