- SDK Version: 1.3.0
- Screenshots of error:
Is there any way for the modal to return errors that we can handle? Or to know if there are geographical restrictions for users for example? We are using cyan but most of our users are in the middle east (i.e. Lebanon).
Sometimes the modal works, sometimes it doesn’t, but we have no access to error logs when it doesn’t work. Is there a way for the modal to throw an exception that we can get visibility on, rather than just presenting an error message to the user?
Please provide the Web3Auth initialization and login code snippet below:
Init code
final loginConfig = HashMap<String, LoginConfigItem>();
loginConfig['jwt'] = LoginConfigItem(
verifier: Env.web3authVerifier, // get it from web3auth dashboard
typeOfLogin: TypeOfLogin.jwt,
name: "firebase",
clientId: Env.web3authCliendId, // web3auth's plug and play client id
);
Network web3authNetwork;
if (Env.firebaseProjectId == "our-id") {
web3authNetwork = Network.cyan;
} else {
web3authNetwork = Network.testnet;
}
await Web3AuthFlutter.init(
Web3AuthOptions(
clientId: Env.web3authCliendId,
network: web3authNetwork,
redirectUrl: redirectUrl,
loginConfig: loginConfig,
),
);
Login code
Future launchWeb3Auth() async {
final firestoreUser = context.read<FirestoreUser?>();
try {
final prefs = await SharedPreferences.getInstance();
var idToken = (await FirebaseAuth.instance.currentUser!.getIdToken(true))
.toString();
if (Env.useEmulator) {
idToken = await signJwtLocallyForWeb3Auth(idToken);
}
final Web3AuthResponse result = await Web3AuthFlutter.login(
LoginParams(
mfaLevel: web3enums.MFALevel.NONE,
loginProvider: web3enums.Provider.jwt,
extraLoginOptions: ExtraLoginOptions(
id_token: idToken,
domain: "firebase",
),
),
);
} on UserCancelledException {
logger.e("User cancelled.");
await signOut();
} on PlatformException catch (e) {
logger.e("Platform exception.");
if (e.code == "LoginFailedException") {
await signOut();
}
} catch (e) {
logger.e(e);
await signOut();
}
}
Log out code
Future<void> signOut() async {
try {
// Clear private key
SharedPreferences preferences = await SharedPreferences.getInstance();
final pk = preferences.get("privateKey");
if (pk != null && pk != "") {
// await Web3AuthFlutter.logout(); // THIS LOGOUT IS NOT WORKING
await preferences.clear();
}
await FirebaseAuth.instance.signOut();
} catch (e) {
logger.e(e);
showSnackBar("An unexpected error has occurred");
}
}```