WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
384c6bd
feat: auth services v10 changes.
grvgoel81 Apr 10, 2025
a417645
feat: update UserInfo
grvgoel81 Apr 14, 2025
2a8b259
feat: wallet-services changes added and update example.
grvgoel81 Apr 15, 2025
1ceec38
feat: update example and bump auth-services version
grvgoel81 Apr 21, 2025
954f652
feat: update example and bump auth-services version
grvgoel81 Apr 23, 2025
95b3770
feat: update sdk inputs
grvgoel81 Apr 23, 2025
5d11e38
feat: Rename ChainsConfig to ChainConfig
grvgoel81 Apr 25, 2025
4eb997c
feat: update variables names and android sdk
grvgoel81 Apr 25, 2025
aed178f
feat: Update pubspec.yaml
grvgoel81 Apr 28, 2025
0f6f226
feat: default value for authConnectionConfig
grvgoel81 Apr 28, 2025
523d7b7
feat: changed authConnection jwt to custom
grvgoel81 Apr 29, 2025
a1c557b
feat: variable naming changes
grvgoel81 May 13, 2025
2c018c4
feat: update LoginParams
grvgoel81 May 14, 2025
c533d2f
feat: update LoginParams
grvgoel81 May 14, 2025
f7bcce8
feat: update wallet-services to v5 version
grvgoel81 May 14, 2025
36daf96
feat: update ExtraLoginOptions
grvgoel81 May 15, 2025
ddf64fa
feat: update android code
grvgoel81 May 19, 2025
e2df060
feat: update input.dart
grvgoel81 May 19, 2025
f164b3a
feat: combined sdk android code initial commit
grvgoel81 Jun 5, 2025
ba50b30
feat: Rename login to connectTo
grvgoel81 Jun 10, 2025
d359522
feat: add whitelabel in Web3AuthOptions
grvgoel81 Jun 11, 2025
85d55ed
feat: add SFA example
grvgoel81 Jun 16, 2025
6f13df3
feat: update android sdk testing version
grvgoel81 Jun 23, 2025
17949df
feat: EmailFlowType default value added
grvgoel81 Jul 10, 2025
f5b738b
feat: update androud sdk
grvgoel81 Jul 14, 2025
87134a1
feat: update example
grvgoel81 Jul 15, 2025
885c61d
feat: optimize imports
grvgoel81 Jul 25, 2025
e818026
Merge remote-tracking branch 'origin/feat/auth_services_v10_changes' …
grvgoel81 Jul 25, 2025
42f2b6b
feat: bump authDashboardVersion to v10.
grvgoel81 Jul 30, 2025
14407a0
feat: swift method changes
grvgoel81 Jul 31, 2025
77c35f3
feat: flutter android analytics added
grvgoel81 Aug 8, 2025
8770759
feat: update android sdk and revert analytics change
grvgoel81 Nov 10, 2025
025c962
feat: update flutter swift sdk.
grvgoel81 Nov 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ android {
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3'
implementation 'com.github.Web3Auth:web3auth-android-sdk:9.1.3'
implementation 'com.github.Web3Auth:web3auth-android-sdk:10.0.0'
implementation 'com.google.code.gson:gson:2.10.1'
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.web3auth.flutter.web3auth_flutter
import android.app.Activity
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.util.Log
import androidx.annotation.Keep
import androidx.annotation.NonNull
Expand All @@ -12,7 +11,6 @@ import com.google.gson.JsonArray
import com.google.gson.JsonElement
import com.google.gson.JsonPrimitive
import com.web3auth.core.Web3Auth
import com.web3auth.core.types.ChainConfig
import com.web3auth.core.types.ErrorCode
import com.web3auth.core.types.LoginParams
import com.web3auth.core.types.Web3AuthError
Expand Down Expand Up @@ -99,7 +97,8 @@ class Web3AuthFlutterPlugin : FlutterPlugin, ActivityAware, MethodCallHandler,
val initParams = gson.fromJson(initArgs, Web3AuthOptions::class.java)
// handle custom parameters which are gson excluded
val obj = JSONObject(initArgs)
if (obj.has("redirectUrl")) initParams.redirectUrl = Uri.parse(obj.get("redirectUrl") as String?)
if (obj.has("redirectUrl")) initParams.redirectUrl =
obj.get("redirectUrl").toString()
// Log.d(initParams.toString(), "#initParams")
web3auth = Web3Auth(
initParams, activity!!
Expand All @@ -111,14 +110,13 @@ class Web3AuthFlutterPlugin : FlutterPlugin, ActivityAware, MethodCallHandler,
return null
}

"login" -> {
"connectTo" -> {
try {
val loginArgs = call.arguments<String>() ?: return null
val loginParams = gson.fromJson(loginArgs, LoginParams::class.java)
val obj = JSONObject(loginArgs)
if (obj.has("redirectUrl")) loginParams.redirectUrl = Uri.parse(obj.get("redirectUrl") as String?)
val loginCF = web3auth.login(loginParams)
// Log.d(loginParams.toString(), "#loginParams")
//Log.d("#loginParams", loginParams.toString())
val loginCF = web3auth.connectTo(loginParams)
Log.d("${Web3AuthFlutterPlugin::class.qualifiedName}", "#login")
val loginResult: Web3AuthResponse = loginCF.get()
return gson.toJson(loginResult)
Expand Down Expand Up @@ -151,15 +149,15 @@ class Web3AuthFlutterPlugin : FlutterPlugin, ActivityAware, MethodCallHandler,
}
}

"getPrivKey" -> {
val privKey = web3auth.getPrivkey()
Log.d("${Web3AuthFlutterPlugin::class.qualifiedName}", "#getPrivKey")
"getPrivateKey" -> {
val privKey = web3auth.getPrivateKey()
Log.d("${Web3AuthFlutterPlugin::class.qualifiedName}", "#getPrivateKey")
return privKey
}

"getEd25519PrivKey" -> {
val ed25519Key = web3auth.getEd25519PrivKey()
Log.d("${Web3AuthFlutterPlugin::class.qualifiedName}", "#getEd25519PrivKey")
"getEd25519PrivateKey" -> {
val ed25519Key = web3auth.getEd25519PrivateKey()
Log.d("${Web3AuthFlutterPlugin::class.qualifiedName}", "#getEd25519PrivateKey")
return ed25519Key
}

Expand Down Expand Up @@ -189,14 +187,13 @@ class Web3AuthFlutterPlugin : FlutterPlugin, ActivityAware, MethodCallHandler,
}
}

"launchWalletServices" -> {
"showWalletUI" -> {
try {
Log.d("${Web3AuthFlutterPlugin::class.qualifiedName}", "#launchWalletServices")
Log.d("${Web3AuthFlutterPlugin::class.qualifiedName}", "#showWalletUI")
val wsArgs = call.arguments<String>() ?: return null
val wsParams = gson.fromJson(wsArgs, WalletServicesJson::class.java)
Log.d(wsParams.toString(), "#wsParams")
val launchWalletCF = web3auth.launchWalletServices(
wsParams.chainConfig,
val launchWalletCF = web3auth.showWalletUI(
wsParams.path
)
launchWalletCF.get()
Expand All @@ -213,8 +210,6 @@ class Web3AuthFlutterPlugin : FlutterPlugin, ActivityAware, MethodCallHandler,
val loginArgs = call.arguments<String>() ?: return null
val loginParams = gson.fromJson(loginArgs, LoginParams::class.java)
val obj = JSONObject(loginArgs)
if (obj.has("redirectUrl")) loginParams.redirectUrl =
Uri.parse(obj.get("redirectUrl") as String?)
val setupMfaCF = web3auth.enableMFA(loginParams)
Log.d("${Web3AuthFlutterPlugin::class.qualifiedName}", "#enableMFA")
return setupMfaCF.get()
Expand All @@ -241,12 +236,11 @@ class Web3AuthFlutterPlugin : FlutterPlugin, ActivityAware, MethodCallHandler,

"request" -> {
try {
Log.d("${Web3AuthFlutterPlugin::class.qualifiedName}", "#signMessage")
Log.d("${Web3AuthFlutterPlugin::class.qualifiedName}", "#request")
val requestArgs = call.arguments<String>() ?: return null
val reqParams = gson.fromJson(requestArgs, RequestJson::class.java)
Log.d(reqParams.toString(), "#reqParams")
val requestCF = web3auth.request(
reqParams.chainConfig,
reqParams.method,
convertListToJsonArray(reqParams.requestParams) ,
reqParams.path,
Expand All @@ -265,8 +259,6 @@ class Web3AuthFlutterPlugin : FlutterPlugin, ActivityAware, MethodCallHandler,
val loginArgs = call.arguments<String>() ?: return null
val loginParams = gson.fromJson(loginArgs, LoginParams::class.java)
val obj = JSONObject(loginArgs)
if (obj.has("redirectUrl")) loginParams.redirectUrl =
Uri.parse(obj.get("redirectUrl") as String?)
val setupMfaCF = web3auth.manageMFA(loginParams)
Log.d("${Web3AuthFlutterPlugin::class.qualifiedName}", "#enableMFA")
return setupMfaCF.get()
Expand Down Expand Up @@ -301,13 +293,11 @@ class Web3AuthFlutterPlugin : FlutterPlugin, ActivityAware, MethodCallHandler,
}
@Keep
data class WalletServicesJson(
@Keep val chainConfig: ChainConfig,
@Keep val path: String? = "wallet"
)

@Keep
data class RequestJson(
@Keep val chainConfig: ChainConfig,
@Keep val method: String,
@Keep val requestParams: List<Any?>,
@Keep val path: String? = "wallet/request",
Expand Down
96 changes: 52 additions & 44 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:web3auth_flutter/enums.dart';
import 'package:web3auth_flutter/input.dart';
import 'package:web3auth_flutter/output.dart';
import 'package:web3auth_flutter/web3auth_flutter.dart';
import 'package:web3auth_flutter_example/utils.dart';
import 'package:web3dart/web3dart.dart';

void main() {
Expand Down Expand Up @@ -53,39 +54,35 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
HashMap themeMap = HashMap<String, String>();
themeMap['primary'] = "#229954";

Uri redirectUrl;
String redirectUrl;
if (Platform.isAndroid) {
redirectUrl = Uri.parse('torusapp://org.torusresearch.flutter.web3authexample');
redirectUrl = 'torusapp://org.torusresearch.flutter.web3authexample';
} else if (Platform.isIOS) {
redirectUrl =
Uri.parse('com.web3auth.flutter.web3authflutterexample://auth');
redirectUrl = 'com.web3auth.flutter.web3authflutterexample://auth';
} else {
throw UnKnownException('Unknown platform');
}

final loginConfig = HashMap<String, LoginConfigItem>();
loginConfig['jwt'] = LoginConfigItem(
verifier: "w3a-auth0-demo", // get it from web3auth dashboard
typeOfLogin: TypeOfLogin.jwt,
clientId: "hUVVf4SEsZT7syOiL0gLU9hFEtm2gQ6O" // auth0 client id
);
final List<AuthConnectionConfig> authConnectionConfig = [
AuthConnectionConfig(
authConnectionId: "web3auth-auth0-email-passwordless-sapphire-devnet",
authConnection: AuthConnection.custom,
clientId: "d84f6xvbdV75VTGmHiMWfZLeSPk8M07C",
)
];

await Web3AuthFlutter.init(
Web3AuthOptions(
clientId:
'BHgArYmWwSeq21czpcarYh0EVq2WWOzflX-NTK-tY1-1pauPzHKRRLgpABkmYiIV_og9jAvoIxQ8L3Smrwe04Lw',
'BPi5PB_UiIZ-cPz1GtV5i1I2iOSOHuimiXBI0e-Oe_u6X3oVAbCiAZOTEBtTXw4tsluTITPqA8zMsfxIKMjiqNQ',
//sdkUrl: 'https://auth.mocaverse.xyz',
//walletSdkUrl: 'https://lrc-mocaverse.web3auth.io',
network: Network.sapphire_devnet,
buildEnv: BuildEnv.production,
web3AuthNetwork: Web3AuthNetwork.sapphire_mainnet,
authBuildEnv: BuildEnv.testing,
redirectUrl: redirectUrl,
whiteLabel: WhiteLabelData(
mode: ThemeModes.dark,
defaultLanguage: Language.en,
appName: "Web3Auth Flutter App",
theme: themeMap,
),
loginConfig: loginConfig,
authConnectionConfig: authConnectionConfig,
defaultChainId: "0x1",
isFlutterAnalytics: true,
),
);

Expand All @@ -95,7 +92,7 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
print('Error during Web3Auth initialization: $e');
}

final String res = await Web3AuthFlutter.getPrivKey();
final String res = await Web3AuthFlutter.getPrivateKey();
log(res);
if (res.isNotEmpty) {
setState(() {
Expand Down Expand Up @@ -186,6 +183,10 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
onPressed: _login(_withDiscord),
child: const Text('Discord'),
),
ElevatedButton(
onPressed: _login(sfaSignIn),
child: const Text('SFA SignIn'),
),
],
),
),
Expand Down Expand Up @@ -213,8 +214,8 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
child: const Text('Launch Wallet Services'),
),
ElevatedButton(
onPressed: _setupMFA(),
child: const Text('Setup MFA'),
onPressed: _enableMFA(),
child: const Text('Enable MFA'),
),
ElevatedButton(
onPressed: _manageMFA(),
Expand Down Expand Up @@ -267,7 +268,7 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
logoutVisible = false;
});
} on UserCancelledException {
log("User cancelled.");
log("User cancelled");
} on UnKnownException {
log("Unknown exception occurred");
}
Expand All @@ -277,7 +278,7 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
VoidCallback _privKey(Future<String?> Function() method) {
return () async {
try {
final String response = await Web3AuthFlutter.getPrivKey();
final String response = await Web3AuthFlutter.getPrivateKey();
setState(() {
_result = response;
logoutVisible = true;
Expand All @@ -290,10 +291,10 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
};
}

VoidCallback _userInfo(Future<TorusUserInfo> Function() method) {
VoidCallback _userInfo(Future<UserInfo> Function() method) {
return () async {
try {
final TorusUserInfo response = await Web3AuthFlutter.getUserInfo();
final UserInfo response = await Web3AuthFlutter.getUserInfo();
setState(() {
_result = response.toString();
logoutVisible = true;
Expand All @@ -307,19 +308,24 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
}

Future<Web3AuthResponse> _withGoogle() {
return Web3AuthFlutter.login(
LoginParams(loginProvider: Provider.google, mfaLevel: MFALevel.NONE),
return Web3AuthFlutter.connectTo(
LoginParams(
authConnection: AuthConnection.google,
authConnectionId: "w3ads",
groupedAuthConnectionId: "aggregate-mobile",
mfaLevel: MFALevel.NONE),
);
}

Future<Web3AuthResponse> _withFacebook() {
return Web3AuthFlutter.login(LoginParams(loginProvider: Provider.facebook));
return Web3AuthFlutter.connectTo(
LoginParams(authConnection: AuthConnection.facebook));
}

Future<Web3AuthResponse> _withEmailPasswordless() {
return Web3AuthFlutter.login(
return Web3AuthFlutter.connectTo(
LoginParams(
loginProvider: Provider.email_passwordless,
authConnection: AuthConnection.email_passwordless,
extraLoginOptions: ExtraLoginOptions(
login_hint: textEditingController.text,
),
Expand All @@ -328,27 +334,30 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
}

Future<Web3AuthResponse> _withDiscord() {
return Web3AuthFlutter.login(LoginParams(loginProvider: Provider.discord));
return Web3AuthFlutter.connectTo(
LoginParams(authConnection: AuthConnection.discord));
}

Future<Web3AuthResponse> sfaSignIn() {
return Web3AuthFlutter.connectTo(
LoginParams(authConnection: AuthConnection.google,
authConnectionId: "torus-test-health",
idToken: Utils().es256Token("[email protected]"),
groupedAuthConnectionId: "torus-aggregate-sapphire-mainnet"));
}

Future<String?> _getPrivKey() {
return Web3AuthFlutter.getPrivKey();
return Web3AuthFlutter.getPrivateKey();
}

Future<TorusUserInfo> _getUserInfo() {
Future<UserInfo> _getUserInfo() {
return Web3AuthFlutter.getUserInfo();
}

VoidCallback _launchWalletServices() {
return () async {
try {
await Web3AuthFlutter.launchWalletServices(
ChainConfig(
chainId: "0x89",
rpcTarget:
"https://mainnet.infura.io/v3/daeee53504be4cd3a997d4f2718d33e0",
),
);
await Web3AuthFlutter.showWalletUI();
} on UserCancelledException {
log("User cancelled.");
} on UnKnownException {
Expand All @@ -357,7 +366,7 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
};
}

VoidCallback _setupMFA() {
VoidCallback _enableMFA() {
return () async {
try {
await Web3AuthFlutter.enableMFA();
Expand Down Expand Up @@ -397,7 +406,6 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
params.add(address.hexEip55);
params.add("Web3Auth");
final signResponse = await Web3AuthFlutter.request(
ChainConfig(chainId: "0x89", rpcTarget: "https://polygon-rpc.com/"),
"personal_sign",
params,
appState: "web3auth",
Expand Down
32 changes: 32 additions & 0 deletions example/lib/utils.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import 'package:dart_jsonwebtoken/dart_jsonwebtoken.dart';

class Utils {
String es256Token(String email) {
String token;

/* Sign */ {
// Create a json web token
final jwt = JWT({
"sub": "email|hello",
"aud": "torus-key-test",
"exp": DateTime.now().millisecond,
"iat": DateTime.now().millisecond,
"iss": "torus-key-test",
"email": email,
"nickname": email.split("@")[0],
"name": email,
"picture": "",
"email_verified": true
});

// Sign it
final key = ECPrivateKey("-----BEGIN PRIVATE KEY-----\n"
"MEECAQAwEwYHKoZIzj0CAQYIKoZIzj0DAQcEJzAlAgEBBCCD7oLrcKae+jVZPGx52Cb/lKhdKxpXjl9eGNa1MlY57A=="
"\n-----END PRIVATE KEY-----");
token = jwt.sign(key, algorithm: JWTAlgorithm.ES256);

print('Signed token: \n $token\n');
return token;
}
}
}
1 change: 1 addition & 0 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ dependencies:
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.8
web3dart: ^2.7.3
dart_jsonwebtoken: ^2.7.1

dev_dependencies:
flutter_test:
Expand Down
Loading