Skip to content

Commit

Permalink
rename to single factor auth flutter
Browse files Browse the repository at this point in the history
  • Loading branch information
chaitanyapotti committed Aug 8, 2023
1 parent 3d45523 commit 388bb6e
Show file tree
Hide file tree
Showing 28 changed files with 131 additions and 104 deletions.
22 changes: 21 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1 +1,21 @@
TODO: Add your license here.
MIT License

Copyright (c) 2020 Torus

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
group 'com.web3auth.single_fact_auth_flutter'
group 'com.web3auth.single_factor_auth_flutter'
version '1.0-SNAPSHOT'

buildscript {
Expand Down
2 changes: 1 addition & 1 deletion android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1 @@
rootProject.name = 'single_fact_auth_flutter'
rootProject.name = 'single_factor_auth_flutter'
2 changes: 1 addition & 1 deletion android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.web3auth.single_fact_auth_flutter">
package="com.web3auth.single_factor_auth_flutter">
</manifest>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.web3auth.single_fact_auth_flutter
package com.web3auth.single_factor_auth_flutter

import android.content.Context
import android.util.Log
Expand All @@ -17,8 +17,8 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import org.torusresearch.fetchnodedetails.types.TorusNetwork

/** SingleFactAuthFlutterPlugin */
class SingleFactAuthFlutterPlugin : FlutterPlugin, MethodCallHandler {
/** SingleFactorAuthFlutterPlugin */
class SingleFactorAuthFlutterPlugin : FlutterPlugin, MethodCallHandler {
/// The MethodChannel that will the communication between Flutter and native Android
///
/// This local reference serves to register the plugin with the Flutter Engine and unregister it
Expand All @@ -31,7 +31,7 @@ class SingleFactAuthFlutterPlugin : FlutterPlugin, MethodCallHandler {
private var gson: Gson = Gson()

override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
channel = MethodChannel(flutterPluginBinding.binaryMessenger, "single_fact_auth_flutter")
channel = MethodChannel(flutterPluginBinding.binaryMessenger, "single_factor_auth_flutter")
channel.setMethodCallHandler(this)
context = flutterPluginBinding.applicationContext
}
Expand Down Expand Up @@ -80,7 +80,7 @@ class SingleFactAuthFlutterPlugin : FlutterPlugin, MethodCallHandler {
"initialize" -> {
try {
val torusKeyCF = singleFactorAuth.initialize(context)
Log.d("${SingleFactAuthFlutterPlugin::class.qualifiedName}", "#initialize")
Log.d("${SingleFactorAuthFlutterPlugin::class.qualifiedName}", "#initialize")
return if (torusKeyCF.get() != null) {
gson.toJson(torusKeyCF.get())
} else {
Expand All @@ -100,7 +100,7 @@ class SingleFactAuthFlutterPlugin : FlutterPlugin, MethodCallHandler {
params.idToken
)
val torusKeyCF = singleFactorAuth.getKey(loginParams, context)
Log.d("${SingleFactAuthFlutterPlugin::class.qualifiedName}", "#getTorusKey")
Log.d("${SingleFactorAuthFlutterPlugin::class.qualifiedName}", "#getTorusKey")
return gson.toJson(torusKeyCF.get())
} catch (e: Throwable) {
throw Error(e)
Expand All @@ -123,7 +123,7 @@ class SingleFactAuthFlutterPlugin : FlutterPlugin, MethodCallHandler {
)
val torusKeyCF = singleFactorAuth.getKey(loginParams, context)
Log.d(
"${SingleFactAuthFlutterPlugin::class.qualifiedName}",
"${SingleFactorAuthFlutterPlugin::class.qualifiedName}",
"#getAggregateTorusKey"
)
return gson.toJson(torusKeyCF.get())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package com.web3auth.single_fact_auth_flutter
package com.web3auth.single_factor_auth_flutter

data class Web3AuthNetwork(val network: String)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.web3auth.single_fact_auth_flutter
package com.web3auth.single_factor_auth_flutter

data class Web3AuthOptions(
val verifier: String,
Expand Down
4 changes: 2 additions & 2 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# single_fact_auth_flutter_example
# single_factor_auth_flutter_example

Demonstrates how to use the single_fact_auth_flutter plugin.
Demonstrates how to use the single_factor_auth_flutter plugin.

## Getting Started

Expand Down
2 changes: 1 addition & 1 deletion example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ android {

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.web3auth.single_fact_auth_flutter_example"
applicationId "com.web3auth.single_factor_auth_flutter_example"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion 24
Expand Down
2 changes: 1 addition & 1 deletion example/android/app/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.web3auth.single_fact_auth_flutter_example">
package="com.web3auth.single_factor_auth_flutter_example">
<!-- The INTERNET permission is required for development. Specifically,
the Flutter tool needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
Expand Down
4 changes: 2 additions & 2 deletions example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.web3auth.single_fact_auth_flutter_example">
package="com.web3auth.single_factor_auth_flutter_example">
<application
android:label="single_fact_auth_flutter_example"
android:label="single_factor_auth_flutter_example"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
<activity
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.web3auth.single_fact_auth_flutter_example
package com.web3auth.single_factor_auth_flutter_example

import io.flutter.embedding.android.FlutterActivity

Expand Down
2 changes: 1 addition & 1 deletion example/android/app/src/profile/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.web3auth.single_fact_auth_flutter_example">
package="com.web3auth.single_factor_auth_flutter_example">
<!-- The INTERNET permission is required for development. Specifically,
the Flutter tool needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
Expand Down
10 changes: 5 additions & 5 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ PODS:
- GenericJSON (2.0.2)
- KeychainSwift (20.0.0)
- secp256k1.swift (0.1.4)
- single_fact_auth_flutter (0.0.1):
- single_factor_auth_flutter (0.0.1):
- Flutter
- SingleFactorAuth (~> 2.0.3)
- SingleFactorAuth (2.0.3):
Expand All @@ -29,7 +29,7 @@ PODS:

DEPENDENCIES:
- Flutter (from `Flutter`)
- single_fact_auth_flutter (from `.symlinks/plugins/single_fact_auth_flutter/ios`)
- single_factor_auth_flutter (from `.symlinks/plugins/single_factor_auth_flutter/ios`)

SPEC REPOS:
trunk:
Expand All @@ -47,8 +47,8 @@ SPEC REPOS:
EXTERNAL SOURCES:
Flutter:
:path: Flutter
single_fact_auth_flutter:
:path: ".symlinks/plugins/single_fact_auth_flutter/ios"
single_factor_auth_flutter:
:path: ".symlinks/plugins/single_factor_auth_flutter/ios"

SPEC CHECKSUMS:
BigInt: 74b4d88367b0e819d9f77393549226d36faeb0d8
Expand All @@ -57,7 +57,7 @@ SPEC CHECKSUMS:
GenericJSON: 79a840eeb77030962e8cf02a62d36bd413b67626
KeychainSwift: 0ce6a4d13f7228054d1a71bb1b500448fb2ab837
secp256k1.swift: a7e7a214f6db6ce5db32cc6b2b45e5c4dd633634
single_fact_auth_flutter: dcb9a0a6052242d1366cebf0ffbbfd9db11b9637
single_factor_auth_flutter: dc31ec16f89101af2d7be3a0f4f807889dc96726
SingleFactorAuth: 9aa82543902e2a4de5a0a456a294eed5d3816d9d
Torus-fetchNodeDetails: a92d02f1bfe91bd61c90f92d64df023babaa5bfa
Torus-utils: 9ac46eb76935e328a6628108c94b66e1af1e7fa7
Expand Down
2 changes: 1 addition & 1 deletion example/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>single_fact_auth_flutter_example</string>
<string>single_factor_auth_flutter_example</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
Expand Down
34 changes: 18 additions & 16 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import 'dart:async';
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:single_fact_auth_flutter/input.dart';
import 'package:single_fact_auth_flutter/single_fact_auth_flutter.dart';
import 'package:single_factor_auth_flutter/input.dart';
import 'package:single_factor_auth_flutter/single_factor_auth_flutter.dart';

void main() {
runApp(const MyApp());
Expand All @@ -17,7 +17,7 @@ class MyApp extends StatefulWidget {
}

class _MyAppState extends State<MyApp> {
final _singleFactAuthFlutterPlugin = SingleFactAuthFlutter();
final _SingleFactorAuthFlutterPlugin = SingleFactAuthFlutter();
String _result = '';
bool logoutVisible = false;
TorusNetwork torusNetwork = TorusNetwork.testnet;
Expand All @@ -29,29 +29,30 @@ class _MyAppState extends State<MyApp> {
}

Future<void> initSdk() async {
if(Platform.isAndroid) {
init().then((value) => initialize());
if (Platform.isAndroid) {
init().then((value) => initialize());
} else if (Platform.isIOS) {
init();
initialize();
} else {}
init();
initialize();
} else {}
}

Future<void> init() async {
await _singleFactAuthFlutterPlugin
.init(Web3AuthNetwork(network: torusNetwork));
await _SingleFactorAuthFlutterPlugin.init(
Web3AuthNetwork(network: torusNetwork));
}

Future<void> initialize() async {
print("initialize() called");
final String torusKey = await _singleFactAuthFlutterPlugin.initialize();
final String torusKey = await _SingleFactorAuthFlutterPlugin.initialize();
if (torusKey.isNotEmpty) {
setState(() {
_result = "Private Key : $torusKey";
});
}
}
}

@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
Expand Down Expand Up @@ -129,7 +130,7 @@ class _MyAppState extends State<MyApp> {
try {
final String response = await method();
setState(() {
_result = "Private Key : $response";
_result = "Private Key : $response";
});
} on UserCancelledException {
print("User cancelled.");
Expand All @@ -142,7 +143,8 @@ class _MyAppState extends State<MyApp> {
VoidCallback _initialize() {
return () async {
try {
final String response = await _singleFactAuthFlutterPlugin.initialize();
final String response =
await _SingleFactorAuthFlutterPlugin.initialize();
setState(() {
_result = "Private Key : $response";
});
Expand All @@ -155,14 +157,14 @@ class _MyAppState extends State<MyApp> {
}

Future<String> testnetTorusKey() {
return _singleFactAuthFlutterPlugin.getTorusKey(Web3AuthOptions(
return _SingleFactorAuthFlutterPlugin.getTorusKey(Web3AuthOptions(
verifier: 'torus-test-health',
email: '[email protected]',
idToken: Utils().es256Token("[email protected]")));
}

Future<String> getAggregrateTorusKey() {
return _singleFactAuthFlutterPlugin.getAggregateTorusKey(Web3AuthOptions(
return _SingleFactorAuthFlutterPlugin.getAggregateTorusKey(Web3AuthOptions(
verifier: 'torus-test-health',
email: '[email protected]',
idToken: Utils().es256Token("[email protected]"),
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.6.2"
single_fact_auth_flutter:
single_factor_auth_flutter:
dependency: "direct main"
description:
path: ".."
Expand Down
13 changes: 6 additions & 7 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: single_fact_auth_flutter_example
description: Demonstrates how to use the single_fact_auth_flutter plugin.
name: single_factor_auth_flutter_example
description: Demonstrates how to use the single_factor_auth_flutter plugin.
# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
publish_to: "none" # Remove this line if you wish to publish to pub.dev

environment:
sdk: '>=2.19.1 <3.0.0'
sdk: ">=2.19.1 <3.0.0"

# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
Expand All @@ -17,9 +17,9 @@ dependencies:
flutter:
sdk: flutter

single_fact_auth_flutter:
single_factor_auth_flutter:
# When depending on this package from a real application you should use:
# single_fact_auth_flutter: ^x.y.z
# single_factor_auth_flutter: ^x.y.z
# See https://dart.dev/tools/pub/dependencies#version-constraints
# The example app is bundled with the plugin so we use a path dependency on
# the parent directory to use the current plugin's version.
Expand All @@ -46,7 +46,6 @@ dev_dependencies:

# The following section is specific to Flutter packages.
flutter:

# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
Expand Down
6 changes: 3 additions & 3 deletions example/test/widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

import 'package:single_fact_auth_flutter_example/main.dart';
import 'package:single_factor_auth_flutter_example/main.dart';

void main() {
testWidgets('Verify Platform version', (WidgetTester tester) async {
Expand All @@ -18,8 +18,8 @@ void main() {
// Verify that platform version is retrieved.
expect(
find.byWidgetPredicate(
(Widget widget) => widget is Text &&
widget.data!.startsWith('Running on:'),
(Widget widget) =>
widget is Text && widget.data!.startsWith('Running on:'),
),
findsOneWidget,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import Flutter
import UIKit
import SingleFactorAuth

public class SingleFactAuthFlutterPlugin: NSObject, FlutterPlugin {
public class SingleFactorAuthFlutterPlugin: NSObject, FlutterPlugin {
public static func register(with registrar: FlutterPluginRegistrar) {
let channel = FlutterMethodChannel(name: "single_fact_auth_flutter", binaryMessenger: registrar.messenger())
let instance = SingleFactAuthFlutterPlugin()
let channel = FlutterMethodChannel(name: "single_factor_auth_flutter", binaryMessenger: registrar.messenger())
let instance = SingleFactorAuthFlutterPlugin()
registrar.addMethodCallDelegate(instance, channel: channel)
}

Expand Down Expand Up @@ -79,7 +79,8 @@ public class SingleFactAuthFlutterPlugin: NSObject, FlutterPlugin {
let params = try self.decoder.decode(getTorusKeyParams.self, from: data)
print(params)

let loginParams = LoginParams(verifier: params.aggregateVerifier, verifierId: params.email, idToken: params.idToken, subVerifierInfoArray: [TorusSubVerifierInfo(verifier: params.verifier, idToken: params.idToken)])
let loginParams = LoginParams(verifier: params.aggregateVerifier, verifierId: params.email, idToken: params.idToken,
subVerifierInfoArray: [TorusSubVerifierInfo(verifier: params.verifier, idToken: params.idToken)])
do {
let torusKeyCF = try await singleFactorAuth?.getKey(loginParams: loginParams)
let resultData = try encoder.encode(torusKeyCF)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html.
# Run `pod lib lint single_fact_auth_flutter.podspec` to validate before publishing.
# Run `pod lib lint single_factor_auth_flutter.podspec` to validate before publishing.
#
Pod::Spec.new do |s|
s.name = 'single_fact_auth_flutter'
s.name = 'single_factor_auth_flutter'
s.version = '0.0.1'
s.summary = 'A new Flutter plugin project.'
s.description = <<-DESC
Expand Down
Loading

0 comments on commit 388bb6e

Please sign in to comment.