diff --git a/mpc-core-kit-ios/mpc-core-kit-ios-auth0/mpc-core-kit-ios-auth0/Helpers/EthereumClient.swift b/mpc-core-kit-ios/mpc-core-kit-ios-auth0/mpc-core-kit-ios-auth0/Helpers/EthereumClient.swift index 0f2b0236..7f0a2012 100644 --- a/mpc-core-kit-ios/mpc-core-kit-ios-auth0/mpc-core-kit-ios-auth0/Helpers/EthereumClient.swift +++ b/mpc-core-kit-ios/mpc-core-kit-ios-auth0/mpc-core-kit-ios-auth0/Helpers/EthereumClient.swift @@ -16,7 +16,7 @@ struct EthereumClient { init() { self.web3Client = EthereumHttpClient( - url: URL(string: "https://1rpc.io/sepolia")!, + url: URL(string: "https://api.web3auth.io/infura-service/v1/11155111/BPi5PB_UiIZ-cPz1GtV5i1I2iOSOHuimiXBI0e-Oe_u6X3oVAbCiAZOTEBtTXw4tsluTITPqA8zMsfxIKMjiqNQ")!, network: .fromString(networkId) ) } diff --git a/mpc-core-kit-ios/mpc-core-kit-ios-quick-start/mpc-core-kit-ios-quick-start/Helpers/EthereumHelper.swift b/mpc-core-kit-ios/mpc-core-kit-ios-quick-start/mpc-core-kit-ios-quick-start/Helpers/EthereumHelper.swift index 639b68a1..987aaf8f 100644 --- a/mpc-core-kit-ios/mpc-core-kit-ios-quick-start/mpc-core-kit-ios-quick-start/Helpers/EthereumHelper.swift +++ b/mpc-core-kit-ios/mpc-core-kit-ios-quick-start/mpc-core-kit-ios-quick-start/Helpers/EthereumHelper.swift @@ -16,7 +16,7 @@ struct EthereumClient { init() { self.web3Client = EthereumHttpClient( - url: URL(string: "https://1rpc.io/sepolia")!, + url: URL(string: "https://api.web3auth.io/infura-service/v1/11155111/BPi5PB_UiIZ-cPz1GtV5i1I2iOSOHuimiXBI0e-Oe_u6X3oVAbCiAZOTEBtTXw4tsluTITPqA8zMsfxIKMjiqNQ")!, network: .fromString(networkId) ) } diff --git a/mpc-core-kit-node/mpc-core-kit-node-quick-start/index.js b/mpc-core-kit-node/mpc-core-kit-node-quick-start/index.js index 9df7da70..26d8d5c6 100644 --- a/mpc-core-kit-node/mpc-core-kit-node-quick-start/index.js +++ b/mpc-core-kit-node/mpc-core-kit-node-quick-start/index.js @@ -77,7 +77,7 @@ async function removeItem(key) { const chainConfig = { chainNamespace: CHAIN_NAMESPACES.EIP155, chainId: "0x1", // Ethereum Mainnet - rpcTarget: "https://rpc.ankr.com/eth", + rpcTarget: `https://api.web3auth.io/infura-service/v1/1/${clientId}`, displayName: "Ethereum Mainnet", blockExplorerUrl: "https://etherscan.io", ticker: "ETH", diff --git a/mpc-core-kit-web/implicit-flow-examples/mpc-core-kit-popup-flow-example/src/App.tsx b/mpc-core-kit-web/implicit-flow-examples/mpc-core-kit-popup-flow-example/src/App.tsx index 73d12ec2..207f47a4 100644 --- a/mpc-core-kit-web/implicit-flow-examples/mpc-core-kit-popup-flow-example/src/App.tsx +++ b/mpc-core-kit-web/implicit-flow-examples/mpc-core-kit-popup-flow-example/src/App.tsx @@ -34,7 +34,7 @@ const web3AuthClientId = "BPi5PB_UiIZ-cPz1GtV5i1I2iOSOHuimiXBI0e-Oe_u6X3oVAbCiAZ const chainConfig = { chainNamespace: CHAIN_NAMESPACES.EIP155, chainId: "0x1", // Please use 0x1 for Mainnet - rpcTarget: "https://rpc.ankr.com/eth", + rpcTarget: `https://api.web3auth.io/infura-service/v1/1/${clientId}`, displayName: "Ethereum Mainnet", blockExplorer: "https://etherscan.io/", ticker: "ETH", diff --git a/mpc-core-kit-web/implicit-flow-examples/mpc-core-kit-redirect-flow-example/src/App.tsx b/mpc-core-kit-web/implicit-flow-examples/mpc-core-kit-redirect-flow-example/src/App.tsx index d68a02ec..f483faa7 100644 --- a/mpc-core-kit-web/implicit-flow-examples/mpc-core-kit-redirect-flow-example/src/App.tsx +++ b/mpc-core-kit-web/implicit-flow-examples/mpc-core-kit-redirect-flow-example/src/App.tsx @@ -35,7 +35,7 @@ const web3AuthClientId = "BPi5PB_UiIZ-cPz1GtV5i1I2iOSOHuimiXBI0e-Oe_u6X3oVAbCiAZ const chainConfig = { chainNamespace: CHAIN_NAMESPACES.EIP155, chainId: "0x1", // Please use 0x1 for Mainnet - rpcTarget: "https://rpc.ankr.com/eth", + rpcTarget: `https://api.web3auth.io/infura-service/v1/1/${clientId}`, displayName: "Ethereum Mainnet", blockExplorer: "https://etherscan.io/", ticker: "ETH", diff --git a/mpc-core-kit-web/quick-starts/mpc-core-kit-vue-quick-start/src/Home.vue b/mpc-core-kit-web/quick-starts/mpc-core-kit-vue-quick-start/src/Home.vue index 9e4d97af..0a84da0a 100644 --- a/mpc-core-kit-web/quick-starts/mpc-core-kit-vue-quick-start/src/Home.vue +++ b/mpc-core-kit-web/quick-starts/mpc-core-kit-vue-quick-start/src/Home.vue @@ -113,7 +113,7 @@ const verifier = "w3a-firebase-demo"; const chainConfig = { chainNamespace: CHAIN_NAMESPACES.EIP155, chainId: "0x1", // Please use 0x1 for Mainnet - rpcTarget: "https://rpc.ankr.com/eth", + rpcTarget: `https://api.web3auth.io/infura-service/v1/1/${clientId}`, displayName: "Ethereum Mainnet", blockExplorer: "https://etherscan.io/", ticker: "ETH", diff --git a/single-factor-auth-android/sfa-android-quick-start/app/src/main/java/com/example/androidsfaexample/MainActivity.kt b/single-factor-auth-android/sfa-android-quick-start/app/src/main/java/com/example/androidsfaexample/MainActivity.kt index 70e5bc1c..8bc0832c 100644 --- a/single-factor-auth-android/sfa-android-quick-start/app/src/main/java/com/example/androidsfaexample/MainActivity.kt +++ b/single-factor-auth-android/sfa-android-quick-start/app/src/main/java/com/example/androidsfaexample/MainActivity.kt @@ -98,7 +98,7 @@ class MainActivity : AppCompatActivity() { val chainConfig = ChainConfig( chainNamespace = ChainNamespace.EIP155, chainId = "0x1", - rpcTarget = "https://rpc.ankr.com/eth" + rpcTarget = "https://api.web3auth.io/infura-service/v1/1/BPi5PB_UiIZ-cPz1GtV5i1I2iOSOHuimiXBI0e-Oe_u6X3oVAbCiAZOTEBtTXw4tsluTITPqA8zMsfxIKMjiqNQ" ) val params = JsonArray().apply { @@ -122,7 +122,7 @@ class MainActivity : AppCompatActivity() { val chainConfig = ChainConfig( chainNamespace = ChainNamespace.EIP155, chainId = "0x1", - rpcTarget = "https://rpc.ankr.com/eth" + rpcTarget = "https://api.web3auth.io/infura-service/v1/1/BPi5PB_UiIZ-cPz1GtV5i1I2iOSOHuimiXBI0e-Oe_u6X3oVAbCiAZOTEBtTXw4tsluTITPqA8zMsfxIKMjiqNQ" ) val launchWalletCompletableFuture = singleFactorAuth.showWalletUI( diff --git a/single-factor-auth-android/sfa-android-quick-start/gradle/wrapper/gradle-wrapper.jar b/single-factor-auth-android/sfa-android-quick-start/gradle/wrapper/gradle-wrapper.jar index e708b1c0..a4b76b95 100644 Binary files a/single-factor-auth-android/sfa-android-quick-start/gradle/wrapper/gradle-wrapper.jar and b/single-factor-auth-android/sfa-android-quick-start/gradle/wrapper/gradle-wrapper.jar differ diff --git a/single-factor-auth-android/sfa-android-quick-start/gradle/wrapper/gradle-wrapper.properties b/single-factor-auth-android/sfa-android-quick-start/gradle/wrapper/gradle-wrapper.properties index 4b558e82..d96302af 100644 --- a/single-factor-auth-android/sfa-android-quick-start/gradle/wrapper/gradle-wrapper.properties +++ b/single-factor-auth-android/sfa-android-quick-start/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ -#Thu Apr 13 13:56:35 IST 2023 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip distributionPath=wrapper/dists -zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists \ No newline at end of file diff --git a/single-factor-auth-android/sfa-android-quick-start/gradlew b/single-factor-auth-android/sfa-android-quick-start/gradlew index 4f906e0c..f5feea6d 100755 --- a/single-factor-auth-android/sfa-android-quick-start/gradlew +++ b/single-factor-auth-android/sfa-android-quick-start/gradlew @@ -1,7 +1,7 @@ -#!/usr/bin/env sh +#!/bin/sh # -# Copyright 2015 the original author or authors. +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,69 +15,104 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s +' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar @@ -87,9 +122,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -98,88 +133,120 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. # For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=`expr $i + 1` + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - 0) set -- ;; - 1) set -- "$args0" ;; - 2) set -- "$args0" "$args1" ;; - 3) set -- "$args0" "$args1" "$args2" ;; - 4) set -- "$args0" "$args1" "$args2" "$args3" ;; - 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=`save "$@"` -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' exec "$JAVACMD" "$@" diff --git a/single-factor-auth-android/sfa-android-quick-start/gradlew.bat b/single-factor-auth-android/sfa-android-quick-start/gradlew.bat index ac1b06f9..9b42019c 100644 --- a/single-factor-auth-android/sfa-android-quick-start/gradlew.bat +++ b/single-factor-auth-android/sfa-android-quick-start/gradlew.bat @@ -13,8 +13,10 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,7 +27,8 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -40,13 +43,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute +if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -56,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -75,13 +78,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/single-factor-auth-flutter/sfa_flutter_aggregate_example/lib/core/ethereum_provider.dart b/single-factor-auth-flutter/sfa_flutter_aggregate_example/lib/core/ethereum_provider.dart index 1a50d464..7d13a672 100644 --- a/single-factor-auth-flutter/sfa_flutter_aggregate_example/lib/core/ethereum_provider.dart +++ b/single-factor-auth-flutter/sfa_flutter_aggregate_example/lib/core/ethereum_provider.dart @@ -11,7 +11,7 @@ class EthereumProvider { EthereumProvider( this._credentials, { - String rpcTarget = "https://1rpc.io/sepolia", + String rpcTarget = "https://api.web3auth.io/infura-service/v1/11155111/BPi5PB_UiIZ-cPz1GtV5i1I2iOSOHuimiXBI0e-Oe_u6X3oVAbCiAZOTEBtTXw4tsluTITPqA8zMsfxIKMjiqNQ", }) : web3client = Web3Client( rpcTarget, Client(), diff --git a/single-factor-auth-ios/sfa-ios-aggregate-example/sfa-ios-aggregate-example/Helpers/EthereumClient.swift b/single-factor-auth-ios/sfa-ios-aggregate-example/sfa-ios-aggregate-example/Helpers/EthereumClient.swift index d69b7198..c513a0a4 100644 --- a/single-factor-auth-ios/sfa-ios-aggregate-example/sfa-ios-aggregate-example/Helpers/EthereumClient.swift +++ b/single-factor-auth-ios/sfa-ios-aggregate-example/sfa-ios-aggregate-example/Helpers/EthereumClient.swift @@ -16,7 +16,7 @@ struct EthereumClient { init() { self.web3Client = EthereumHttpClient( - url: URL(string: "https://1rpc.io/sepolia")!, + url: URL(string: "https://api.web3auth.io/infura-service/v1/11155111/BPi5PB_UiIZ-cPz1GtV5i1I2iOSOHuimiXBI0e-Oe_u6X3oVAbCiAZOTEBtTXw4tsluTITPqA8zMsfxIKMjiqNQ")!, network: .fromString(networkId) ) } diff --git a/single-factor-auth-ios/sfa-ios-quick-start/ios-firebase-example.xcodeproj/project.pbxproj b/single-factor-auth-ios/sfa-ios-quick-start/ios-firebase-example.xcodeproj/project.pbxproj index 6ce89bf3..4eac2f7f 100644 --- a/single-factor-auth-ios/sfa-ios-quick-start/ios-firebase-example.xcodeproj/project.pbxproj +++ b/single-factor-auth-ios/sfa-ios-quick-start/ios-firebase-example.xcodeproj/project.pbxproj @@ -8,7 +8,7 @@ /* Begin PBXBuildFile section */ 0D005DFA29CCB28100F7F4F7 /* FirebaseAuth in Frameworks */ = {isa = PBXBuildFile; productRef = 0D005DF929CCB28100F7F4F7 /* FirebaseAuth */; }; - 27B35B442A3F5A3C0004BB99 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 27B35B432A3F5A3B0004BB99 /* GoogleService-Info.plist */; }; + 27B1B8EF2DA680EE004B68AD /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 27B1B8EE2DA680EE004B68AD /* GoogleService-Info.plist */; }; 284BD7472D7EA570002DD6CA /* SingleFactorAuth in Frameworks */ = {isa = PBXBuildFile; productRef = 284BD7462D7EA570002DD6CA /* SingleFactorAuth */; }; 28A9039F2BC3CD6F002C0DB5 /* EthereumClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 28A9039E2BC3CD6F002C0DB5 /* EthereumClient.swift */; }; 28A903AF2BC3DDFC002C0DB5 /* web3.swift in Frameworks */ = {isa = PBXBuildFile; productRef = 28A903AE2BC3DDFC002C0DB5 /* web3.swift */; }; @@ -42,7 +42,8 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ - 27B35B432A3F5A3B0004BB99 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = ""; }; + 27B1B8EB2DA67566004B68AD /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = ""; }; + 27B1B8EE2DA680EE004B68AD /* GoogleService-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = ""; }; 28A9039E2BC3CD6F002C0DB5 /* EthereumClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EthereumClient.swift; sourceTree = ""; }; 4D9FEEE1294BAC380035414D /* ios-firebase-example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "ios-firebase-example.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 4D9FEEE4294BAC380035414D /* ios_firebase_exampleApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ios_firebase_exampleApp.swift; sourceTree = ""; }; @@ -118,13 +119,14 @@ 4D9FEEE3294BAC380035414D /* ios-firebase-example */ = { isa = PBXGroup; children = ( + 27B1B8EB2DA67566004B68AD /* Info.plist */, 28A9039D2BC3CD55002C0DB5 /* Helpers */, 4D9FEEE4294BAC380035414D /* ios_firebase_exampleApp.swift */, 4D9FEEE6294BAC380035414D /* ContentView.swift */, 4D9FEEE8294BAC3A0035414D /* Assets.xcassets */, 4D9FEEEA294BAC3A0035414D /* Preview Content */, 4D9FEF11294BACB10035414D /* ViewModel.swift */, - 27B35B432A3F5A3B0004BB99 /* GoogleService-Info.plist */, + 27B1B8EE2DA680EE004B68AD /* GoogleService-Info.plist */, 4D9FEF13294BACC90035414D /* UserDetailView.swift */, 4D9FEF15294BACD80035414D /* LoginView.swift */, ); @@ -271,8 +273,8 @@ buildActionMask = 2147483647; files = ( 4D9FEEEC294BAC3A0035414D /* Preview Assets.xcassets in Resources */, - 27B35B442A3F5A3C0004BB99 /* GoogleService-Info.plist in Resources */, 4D9FEEE9294BAC3A0035414D /* Assets.xcassets in Resources */, + 27B1B8EF2DA680EE004B68AD /* GoogleService-Info.plist in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -461,9 +463,10 @@ CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_ASSET_PATHS = "\"ios-firebase-example/Preview Content\""; - DEVELOPMENT_TEAM = 9748CA473J; + DEVELOPMENT_TEAM = 2Q63NCPY55; ENABLE_PREVIEWS = YES; GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = "ios-firebase-example/Info.plist"; INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchScreen_Generation = YES; @@ -490,9 +493,10 @@ CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_ASSET_PATHS = "\"ios-firebase-example/Preview Content\""; - DEVELOPMENT_TEAM = 9748CA473J; + DEVELOPMENT_TEAM = 2Q63NCPY55; ENABLE_PREVIEWS = YES; GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = "ios-firebase-example/Info.plist"; INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchScreen_Generation = YES; diff --git a/single-factor-auth-ios/sfa-ios-quick-start/ios-firebase-example.xcodeproj/project.xcworkspace/xcuserdata/shahbaz.xcuserdatad/UserInterfaceState.xcuserstate b/single-factor-auth-ios/sfa-ios-quick-start/ios-firebase-example.xcodeproj/project.xcworkspace/xcuserdata/shahbaz.xcuserdatad/UserInterfaceState.xcuserstate index 96864fc5..98848f2b 100644 Binary files a/single-factor-auth-ios/sfa-ios-quick-start/ios-firebase-example.xcodeproj/project.xcworkspace/xcuserdata/shahbaz.xcuserdatad/UserInterfaceState.xcuserstate and b/single-factor-auth-ios/sfa-ios-quick-start/ios-firebase-example.xcodeproj/project.xcworkspace/xcuserdata/shahbaz.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/single-factor-auth-ios/sfa-ios-quick-start/ios-firebase-example.xcodeproj/project.xcworkspace/xcuserdata/yashovardhanagrawal.xcuserdatad/UserInterfaceState.xcuserstate b/single-factor-auth-ios/sfa-ios-quick-start/ios-firebase-example.xcodeproj/project.xcworkspace/xcuserdata/yashovardhanagrawal.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 00000000..01539051 Binary files /dev/null and b/single-factor-auth-ios/sfa-ios-quick-start/ios-firebase-example.xcodeproj/project.xcworkspace/xcuserdata/yashovardhanagrawal.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/single-factor-auth-ios/sfa-ios-quick-start/ios-firebase-example.xcodeproj/xcuserdata/yashovardhanagrawal.xcuserdatad/xcschemes/xcschememanagement.plist b/single-factor-auth-ios/sfa-ios-quick-start/ios-firebase-example.xcodeproj/xcuserdata/yashovardhanagrawal.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 00000000..fb5cfdb8 --- /dev/null +++ b/single-factor-auth-ios/sfa-ios-quick-start/ios-firebase-example.xcodeproj/xcuserdata/yashovardhanagrawal.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,14 @@ + + + + + SchemeUserState + + ios-firebase-example.xcscheme_^#shared#^_ + + orderHint + 0 + + + + diff --git a/single-factor-auth-ios/sfa-ios-quick-start/ios-firebase-example/GoogleService-Info.plist b/single-factor-auth-ios/sfa-ios-quick-start/ios-firebase-example/GoogleService-Info.plist index f96861ff..372aae37 100644 --- a/single-factor-auth-ios/sfa-ios-quick-start/ios-firebase-example/GoogleService-Info.plist +++ b/single-factor-auth-ios/sfa-ios-quick-start/ios-firebase-example/GoogleService-Info.plist @@ -7,7 +7,7 @@ REVERSED_CLIENT_ID com.googleusercontent.apps.461819774167-4o61nkm60k8rao4vbvcer22j66li9sco ANDROID_CLIENT_ID - 461819774167-l7oslag3sa2vllbl1b9ghhcf6e6rhvjj.apps.googleusercontent.com + 461819774167-93iair46nluf28pdbpmqq65eqktdbb7g.apps.googleusercontent.com API_KEY AIzaSyAttkINEO4AWRc2jJDHa5fPYp_1EtujcH0 GCM_SENDER_ID @@ -19,7 +19,7 @@ PROJECT_ID web3auth-oauth-logins STORAGE_BUCKET - web3auth-oauth-logins.appspot.com + web3auth-oauth-logins.firebasestorage.app IS_ADS_ENABLED IS_ANALYTICS_ENABLED @@ -32,5 +32,7 @@ GOOGLE_APP_ID 1:461819774167:ios:605db7054cfea4715b9c92 + DATABASE_URL + https://web3auth-oauth-logins-default-rtdb.asia-southeast1.firebasedatabase.app \ No newline at end of file diff --git a/single-factor-auth-ios/sfa-ios-quick-start/ios-firebase-example/Helpers/EthereumClient.swift b/single-factor-auth-ios/sfa-ios-quick-start/ios-firebase-example/Helpers/EthereumClient.swift index e497efea..c6400c2e 100644 --- a/single-factor-auth-ios/sfa-ios-quick-start/ios-firebase-example/Helpers/EthereumClient.swift +++ b/single-factor-auth-ios/sfa-ios-quick-start/ios-firebase-example/Helpers/EthereumClient.swift @@ -26,7 +26,7 @@ struct EthereumClient { init(sessionData: SessionData) { self.web3Client = EthereumHttpClient( - url: URL(string: "https://1rpc.io/sepolia")!, + url: URL(string: "https://api.web3auth.io/infura-service/v1/11155111/BPi5PB_UiIZ-cPz1GtV5i1I2iOSOHuimiXBI0e-Oe_u6X3oVAbCiAZOTEBtTXw4tsluTITPqA8zMsfxIKMjiqNQ")!, network: .fromString(networkId) ) diff --git a/single-factor-auth-ios/sfa-ios-quick-start/ios-firebase-example/Info.plist b/single-factor-auth-ios/sfa-ios-quick-start/ios-firebase-example/Info.plist new file mode 100644 index 00000000..fe297515 --- /dev/null +++ b/single-factor-auth-ios/sfa-ios-quick-start/ios-firebase-example/Info.plist @@ -0,0 +1,17 @@ + + + + + CFBundleURLTypes + + + CFBundleTypeRole + Editor + CFBundleURLSchemes + + app-1-461819774167-ios-605db7054cfea4715b9c92 + + + + + diff --git a/single-factor-auth-ios/sfa-ios-quick-start/ios-firebase-example/LoginView.swift b/single-factor-auth-ios/sfa-ios-quick-start/ios-firebase-example/LoginView.swift index 24350e49..402f015a 100644 --- a/single-factor-auth-ios/sfa-ios-quick-start/ios-firebase-example/LoginView.swift +++ b/single-factor-auth-ios/sfa-ios-quick-start/ios-firebase-example/LoginView.swift @@ -2,19 +2,105 @@ import SwiftUI struct LoginView: View { @StateObject var vm: ViewModel + var body: some View { - List { + VStack(spacing: 24) { + Spacer() + + // X Logo + Text("X") + .font(.system(size: 48, weight: .bold)) + .foregroundColor(.white) + .frame(width: 80, height: 80) + .background(Color.black) + .clipShape(RoundedRectangle(cornerRadius: 16)) + + // Title and Subtitle + VStack(spacing: 16) { + Text("Embedded SDK Demo") + .font(.system(size: 32, weight: .bold)) + .multilineTextAlignment(.center) + + Text("Authenticate with your X account") + .font(.title2) + .foregroundColor(.secondary) + .multilineTextAlignment(.center) + } + + Spacer() + + // Login Button Button( action: { - vm.loginViaFirebaseEP() + vm.loginViaFirebaseX() }, label: { - Label("LogIn", systemImage: "arrow.right.square.fill") - .foregroundColor(.green) + HStack(spacing: 12) { + if vm.isLoading { + ProgressView() + .progressViewStyle(CircularProgressViewStyle(tint: .white)) + .scaleEffect(0.8) + } else { + Image(systemName: "arrow.right") + .foregroundColor(.white) + .font(.system(size: 16, weight: .semibold)) + } + Text("Log in with X") + .foregroundColor(.white) + .font(.system(size: 16, weight: .semibold)) + } + .frame(maxWidth: .infinity) + .frame(height: 52) + .background(Color.black) + .cornerRadius(26) } ) - + .padding(.horizontal, 24) + + // Login Button + Button( + action: { + vm.loginViaFirebaseAnonymous() + }, + label: { + HStack(spacing: 12) { + if vm.isLoading { + ProgressView() + .progressViewStyle(CircularProgressViewStyle(tint: .white)) + .scaleEffect(0.8) + } else { + Image(systemName: "arrow.right") + .foregroundColor(.white) + .font(.system(size: 16, weight: .semibold)) + } + Text("Log in with ID Token") + .foregroundColor(.white) + .font(.system(size: 16, weight: .semibold)) + } + .frame(maxWidth: .infinity) + .frame(height: 52) + .background(Color.black) + .cornerRadius(26) + } + ) + .padding(.horizontal, 24) + + // Bottom Links + HStack(spacing: 40) { + Button("Need help?") { + // Add help action + } + + Button("Privacy Policy") { + // Add privacy policy action + } + } + .font(.system(size: 16)) + .foregroundColor(.secondary) + .padding(.top, 24) + .padding(.bottom, 40) } + .background(Color(uiColor: .systemBackground)) } } diff --git a/single-factor-auth-ios/sfa-ios-quick-start/ios-firebase-example/UserDetailView.swift b/single-factor-auth-ios/sfa-ios-quick-start/ios-firebase-example/UserDetailView.swift index 547d800e..8337390a 100644 --- a/single-factor-auth-ios/sfa-ios-quick-start/ios-firebase-example/UserDetailView.swift +++ b/single-factor-auth-ios/sfa-ios-quick-start/ios-firebase-example/UserDetailView.swift @@ -7,92 +7,262 @@ struct UserDetailView: View { @State private var showingAlert = false @State private var alertContent: String = "" + @State private var isPrivateKeyVisible = false + @State private var recipientAddress: String = "" + @State private var amount: String = "" + @State private var isSending = false + @State private var lastTxHash: String? = nil + @State private var showingTxDetails = false var body: some View { - if !viewModel.isAccountReady { + if viewModel.isLoading { + VStack(spacing: 16) { + ProgressView() + .scaleEffect(1.2) + Text("Logging in...") + .foregroundColor(.gray) + } + } else if !viewModel.isAccountReady { ProgressView() } else { if let user = user { - List { - Section { - Text(viewModel.userBalance) - Text("User balance on Ethereum Sepolia") - } - header: { - Text("User Balance") - } - Section { - Button( - action: { - viewModel.signMessage{ - result, error in - if result != nil { - alertContent = result! - } else { - alertContent = error! + ScrollView { + VStack(alignment: .leading, spacing: 24) { + VStack(alignment: .leading, spacing: 16) { + Text("USER BALANCE") + .font(.subheadline) + .foregroundColor(.gray) + .padding(.horizontal) + + VStack(alignment: .leading, spacing: 8) { + Text(viewModel.userBalance) + .font(.system(size: 24, weight: .regular)) + Text("User balance on Ethereum Sepolia") + .font(.subheadline) + .foregroundColor(.gray) + Link(destination: URL(string: "https://sepolia.etherscan.io/address/\(viewModel.userAccount)")!) { + HStack(spacing: 4) { + Text(viewModel.userAccount) + .lineLimit(1) + .truncationMode(.middle) + Image(systemName: "arrow.up.right.square") + .font(.system(size: 12)) } - showingAlert = true + .font(.system(size: 14)) + .foregroundColor(.blue) } - }, - label: { - Text("Sign Message") } - ) - Button( - action: { - viewModel.requestSignature{ - result, error in - if result != nil { - alertContent = result! - } else { - alertContent = error! + .padding() + .frame(maxWidth: .infinity, alignment: .leading) + .background(Color(uiColor: .secondarySystemBackground)) + .cornerRadius(12) + .padding(.horizontal) + } + + VStack(alignment: .leading, spacing: 16) { + Text("SEND TRANSACTION") + .font(.subheadline) + .foregroundColor(.gray) + .padding(.horizontal) + + VStack(spacing: 16) { + VStack(alignment: .leading, spacing: 8) { + Text("Recipient Address") + .font(.subheadline) + .foregroundColor(.gray) + TextField("0x...", text: $recipientAddress) + .textFieldStyle(RoundedBorderTextFieldStyle()) + .font(.system(.body, design: .monospaced)) + } + + VStack(alignment: .leading, spacing: 8) { + Text("Amount (ETH)") + .font(.subheadline) + .foregroundColor(.gray) + TextField("0.0", text: $amount) + .textFieldStyle(RoundedBorderTextFieldStyle()) + .keyboardType(.decimalPad) + } + + Button(action: { + isSending = true + viewModel.sendTransaction(to: recipientAddress, amount: amount) { success, error, txHash in + isSending = false + if success { + lastTxHash = txHash + showingTxDetails = true + // Clear input fields + recipientAddress = "" + amount = "" + } else { + alertContent = error ?? "Failed to send transaction" + showingAlert = true + } + } + }) { + HStack { + if isSending { + ProgressView() + .progressViewStyle(CircularProgressViewStyle(tint: .white)) + .scaleEffect(0.8) + } else { + Image(systemName: "arrow.up.right") + .foregroundColor(.white) + .font(.system(size: 16, weight: .semibold)) + } + Text("Send") + .foregroundColor(.white) + .font(.system(size: 16, weight: .semibold)) } - showingAlert = true + .frame(maxWidth: .infinity) + .frame(height: 44) + .background(Color.black) + .cornerRadius(22) + } + .disabled(isSending || recipientAddress.isEmpty || amount.isEmpty) + + if showingTxDetails, let hash = lastTxHash { + VStack(alignment: .leading, spacing: 8) { + Text("Transaction sent!") + .font(.headline) + .foregroundColor(.green) + + Link(destination: URL(string: "https://sepolia.etherscan.io/tx/\(hash)")!) { + HStack { + Text("View on Etherscan") + .foregroundColor(.blue) + Image(systemName: "arrow.up.right.square") + .font(.system(size: 12)) + } + } + + Text(hash) + .font(.system(.caption, design: .monospaced)) + .foregroundColor(.gray) + .lineLimit(1) + .truncationMode(.middle) + } + .padding() + .frame(maxWidth: .infinity, alignment: .leading) + .background(Color(uiColor: .tertiarySystemBackground)) + .cornerRadius(12) } - }, - label: { - Text("Request Signature") } - ) - Button( - action: { - viewModel.showWalletUI() - }, - label: { - Text("Show Wallet UI") + .padding() + .background(Color(uiColor: .secondarySystemBackground)) + .cornerRadius(12) + .padding(.horizontal) + } + + VStack(alignment: .leading, spacing: 16) { + Text("CHAIN INTERACTIONS") + .font(.subheadline) + .foregroundColor(.gray) + .padding(.horizontal) + + VStack(spacing: 0) { + Button(action: { + viewModel.getBalance() + }) { + Text("Fetch Latest Balance") + .frame(maxWidth: .infinity, alignment: .leading) + .padding() + } + Divider() + Button(action: { + viewModel.signMessage { result, error in + alertContent = result ?? error ?? "" + showingAlert = true + } + }) { + Text("Sign Message") + .frame(maxWidth: .infinity, alignment: .leading) + .padding() + } + Divider() + Button(action: { + viewModel.requestSignature { result, error in + alertContent = result ?? error ?? "" + showingAlert = true + } + }) { + Text("Request Signature") + .frame(maxWidth: .infinity, alignment: .leading) + .padding() + } + Divider() + Button(action: { + viewModel.showWalletUI() + }) { + Text("Show Wallet UI") + .frame(maxWidth: .infinity, alignment: .leading) + .padding() + } } - ) - } header: { - Text("Chain Interactions") - } - - Section { - Text("\(user)") - } header: { - Text("Private key") - } - - Section { - Button { + .background(Color(uiColor: .secondarySystemBackground)) + .cornerRadius(12) + .padding(.horizontal) + } + + VStack(alignment: .leading, spacing: 16) { + Text("PRIVATE KEY") + .font(.subheadline) + .foregroundColor(.gray) + .padding(.horizontal) + + Text(user) + .font(.system(size: 16)) + .blur(radius: isPrivateKeyVisible ? 0 : 8) + .overlay( + Group { + if !isPrivateKeyVisible { + Text("Tap to reveal") + .foregroundColor(.blue) + .font(.system(size: 14)) + } + } + ) + .padding() + .frame(maxWidth: .infinity, alignment: .leading) + .background(Color(uiColor: .secondarySystemBackground)) + .cornerRadius(12) + .padding(.horizontal) + .onTapGesture { + withAnimation(.easeInOut(duration: 0.2)) { + isPrivateKeyVisible.toggle() + } + } + } + + Button(action: { viewModel.logout() - } label: { - Label("Logout", systemImage: "arrow.left.square.fill") - .foregroundColor(.red) + }) { + HStack { + Image(systemName: "arrow.left") + Text("Logout") + } + .foregroundColor(.red) + .padding() + .frame(maxWidth: .infinity, alignment: .leading) + .background(Color(uiColor: .secondarySystemBackground)) + .cornerRadius(12) + .padding(.horizontal) } + + Spacer() } - }.listStyle(.automatic).alert(isPresented: $showingAlert, content: { + } + .alert(isPresented: $showingAlert) { Alert(title: Text(alertContent)) - }) - + } } } } } - struct UserDetailView_Previews: PreviewProvider { static var previews: some View { let user: String = "privKey" - UserDetailView(user: user , loggedIn: .constant(true), viewModel: ViewModel()) + UserDetailView(user: user, loggedIn: .constant(true), viewModel: ViewModel()) } } diff --git a/single-factor-auth-ios/sfa-ios-quick-start/ios-firebase-example/ViewModel.swift b/single-factor-auth-ios/sfa-ios-quick-start/ios-firebase-example/ViewModel.swift index e4ac4c7c..66d89543 100644 --- a/single-factor-auth-ios/sfa-ios-quick-start/ios-firebase-example/ViewModel.swift +++ b/single-factor-auth-ios/sfa-ios-quick-start/ios-firebase-example/ViewModel.swift @@ -12,7 +12,8 @@ class ViewModel: ObservableObject { var singleFactorAuth: SingleFactorAuth! var web3AuthOptions: Web3AuthOptions! var ethereumClient: EthereumClient! - var userBalance: String! + var userBalance: String = "0.0" + var userAccount: String = "0x0" // IMP END - Installation @Published var loggedIn: Bool = false @@ -21,8 +22,13 @@ class ViewModel: ObservableObject { @Published var navigationTitle: String = "" @Published var isAccountReady: Bool = false - var chainConfig: ChainConfig = ChainConfig(chainId: "0x01", rpcTarget: "https://eth.llamarpc.com") + var chainConfig: ChainConfig = ChainConfig(chainId: "0xaa36a7", rpcTarget: "https://api.web3auth.io/infura-service/v1/11155111/BPi5PB_UiIZ-cPz1GtV5i1I2iOSOHuimiXBI0e-Oe_u6X3oVAbCiAZOTEBtTXw4tsluTITPqA8zMsfxIKMjiqNQ") + init() { + Task { + await setup() + } + } func setup() async { guard singleFactorAuth == nil else { return } @@ -56,19 +62,85 @@ class ViewModel: ObservableObject { await MainActor.run(body: { user = sessionData.privateKey loggedIn = true - navigationTitle = "UserInfo" + navigationTitle = "Profile" }) } await MainActor.run(body: { isLoading = false - navigationTitle = loggedIn ? "UserInfo" : "iOS SFA QuickStart" + navigationTitle = loggedIn ? "Profile" : "" }) } - func loginViaFirebaseEP() { - Task{ + func loginViaFirebaseX() { + Task { do { + await MainActor.run { + isLoading = true + } + + // Twitter OAuth Provider Setup + let provider = OAuthProvider(providerID: "twitter.com") + + // Use async version to get credential + let credential: AuthCredential = try await withCheckedThrowingContinuation { continuation in + provider.getCredentialWith(nil) { credential, error in + if let error = error { + continuation.resume(throwing: error) + } else if let credential = credential { + continuation.resume(returning: credential) + } else { + continuation.resume(throwing: NSError(domain: "FirebaseAuth", code: -1, userInfo: [NSLocalizedDescriptionKey: "Unknown error getting credential"])) + } + } + } + + // Sign in with Twitter credential + let authResult = try await Auth.auth().signIn(with: credential) + let idToken = try await authResult.user.getIDToken() + guard let uid = authResult.user.uid as String?, idToken as String? != nil else { + throw NSError(domain: "FirebaseAuth", code: -2, userInfo: [NSLocalizedDescriptionKey: "Missing UID, or Id Token missing"]) + } + + // Verifier name + let verifierName = "w3a-firebase-demo" + + // Get Web3Auth key + let result = try await singleFactorAuth.connect( + loginParams: .init( + verifier: verifierName, + verifierId: uid, + idToken: idToken + ) + ) + + // Continue with Ethereum client setup and UI update + ethereumClient = EthereumClient(sessionData: result) + getBalance() + + await MainActor.run { + user = result.privateKey + loggedIn = true + navigationTitle = "Profile" + isLoading = false + } + + } catch { + print("Login error: \(error.localizedDescription)") + await MainActor.run { + isLoading = false + } + } + } + } + + func loginViaFirebaseAnonymous() { + Task { + do { + await MainActor.run { + isLoading = true + } + // IMP START - Auth Provider Login let res = try await Auth.auth().signIn(withEmail: "ios@firebase.com", password: "iOS@Web3Auth") let id_token = try await res.user.getIDToken() @@ -77,8 +149,9 @@ class ViewModel: ObservableObject { // IMP START - Verifier Creation let verifierName = "w3a-firebase-demo" // IMP END - Verifier Creation + // IMP START - Get Key - let result = try await singleFactorAuth.connect( + let result = try await singleFactorAuth.connect( loginParams: .init( verifier: verifierName, verifierId: res.user.uid, @@ -86,22 +159,29 @@ class ViewModel: ObservableObject { ) ) // IMP END - Get Key + print(result) + + // Continue with Ethereum client setup and UI update ethereumClient = EthereumClient(sessionData: result) getBalance() - - await MainActor.run(body: { + + await MainActor.run { user = result.privateKey loggedIn = true - navigationTitle = "UserInfo" - }) - + navigationTitle = "Profile" + isLoading = false + } + } catch { - print("Error") + print("Login error: \(error)") + await MainActor.run { + isLoading = false + } } } } - + func showWalletUI() { Task { @@ -143,7 +223,10 @@ class ViewModel: ObservableObject { func getBalance() { Task { do { + let sessionData = singleFactorAuth.getSessionData() + self.userAccount = sessionData!.publicAddress self.userBalance = try await ethereumClient.getBalance() + print("Balance of \(self.userAccount): \(self.userBalance)") await MainActor.run(body: { self.isAccountReady = true }) @@ -159,9 +242,11 @@ class ViewModel: ObservableObject { func logout() { Task { do { - try await singleFactorAuth.logout() + try await singleFactorAuth.logout(); + try Auth.auth().signOut(); await MainActor.run(body: { self.loggedIn = false + navigationTitle = loggedIn ? "Profile" : "" }) } catch let error { print(error) @@ -180,7 +265,50 @@ class ViewModel: ObservableObject { } } + func sendTransaction(to address: String, amount: String, completion: @escaping (Bool, String?, String?) -> Void) { + Task { + do { + guard let amountInWei = try? convertEthToWei(amount) else { + completion(false, "Invalid amount", nil) + return + } + + let sessionData = singleFactorAuth.getSessionData() + // Create transaction object + let transaction: [String: Any] = [ + "from": sessionData!.publicAddress, + "to": address, + "value": amountInWei, + "data": "0x" + ] + + let response = try await singleFactorAuth.request( + chainConfig: chainConfig, + method: "eth_sendTransaction", + requestParams: [transaction] // Send as array with single transaction object + ) + + if response.success { + // response.result contains the transaction hash + completion(true, nil, response.result) + // Refresh balance after successful transaction + getBalance() + } else { + completion(false, response.error, nil) + } + } catch { + completion(false, error.localizedDescription, nil) + } + } + } + private func convertEthToWei(_ eth: String) throws -> String { + guard let ethValue = Double(eth) else { + throw NSError(domain: "Transaction", code: -1, userInfo: [NSLocalizedDescriptionKey: "Invalid amount"]) + } + let weiValue = ethValue * 1e18 + return String(format: "0x%llx", UInt64(weiValue)) + } } extension ViewModel { diff --git a/single-factor-auth-node/github-oauth-connection/index.js b/single-factor-auth-node/github-oauth-connection/index.js index 87fcd16b..83971521 100644 --- a/single-factor-auth-node/github-oauth-connection/index.js +++ b/single-factor-auth-node/github-oauth-connection/index.js @@ -31,7 +31,7 @@ const chainConfig = { tickerName: 'Ethereum', ticker: 'ETH', decimals: 18, - rpcTarget: 'https://rpc.ankr.com/eth', + rpcTarget: `https://api.web3auth.io/infura-service/v1/1/${clientId}`, blockExplorerUrl: 'https://etherscan.io', logo: 'https://cryptologos.cc/logos/ethereum-eth-logo.png', }; diff --git a/single-factor-auth-node/microsoft-oauth-connection/index.ts b/single-factor-auth-node/microsoft-oauth-connection/index.ts index 72d8f7ff..eec69901 100644 --- a/single-factor-auth-node/microsoft-oauth-connection/index.ts +++ b/single-factor-auth-node/microsoft-oauth-connection/index.ts @@ -41,7 +41,7 @@ const chainConfig = { tickerName: 'Ethereum', ticker: 'ETH', decimals: 18, - rpcTarget: 'https://rpc.ankr.com/eth', + rpcTarget: `https://api.web3auth.io/infura-service/v1/1/${clientId}`, blockExplorerUrl: 'https://etherscan.io', logo: 'https://cryptologos.cc/logos/ethereum-eth-logo.png', }; diff --git a/single-factor-auth-node/sfa-node-quick-start/index.js b/single-factor-auth-node/sfa-node-quick-start/index.js index 81418a07..c337ab39 100644 --- a/single-factor-auth-node/sfa-node-quick-start/index.js +++ b/single-factor-auth-node/sfa-node-quick-start/index.js @@ -22,7 +22,7 @@ const chainConfig = { tickerName: 'Ethereum', ticker: 'ETH', decimals: 18, - rpcTarget: 'https://rpc.ankr.com/eth', + rpcTarget: `https://api.web3auth.io/infura-service/v1/1/${clientId}`, blockExplorerUrl: 'https://etherscan.io', logo: 'https://cryptologos.cc/logos/ethereum-eth-logo.png', }; diff --git a/single-factor-auth-node/sfa-telegram-oauth-server/index.js b/single-factor-auth-node/sfa-telegram-oauth-server/index.js index 78548f8c..1412f864 100644 --- a/single-factor-auth-node/sfa-telegram-oauth-server/index.js +++ b/single-factor-auth-node/sfa-telegram-oauth-server/index.js @@ -31,7 +31,7 @@ const chainConfig = { tickerName: 'Ethereum', ticker: 'ETH', decimals: 18, - rpcTarget: 'https://rpc.ankr.com/eth', + rpcTarget: `https://api.web3auth.io/infura-service/v1/1/${clientId}`, blockExplorerUrl: 'https://etherscan.io', logo: 'https://cryptologos.cc/logos/ethereum-eth-logo.png', }; diff --git a/single-factor-auth-react-native/sfa-rn-bare-quick-start/App.tsx b/single-factor-auth-react-native/sfa-rn-bare-quick-start/App.tsx index 06d7822b..5e8c51f6 100644 --- a/single-factor-auth-react-native/sfa-rn-bare-quick-start/App.tsx +++ b/single-factor-auth-react-native/sfa-rn-bare-quick-start/App.tsx @@ -52,7 +52,7 @@ const chainConfig = { tickerName: 'Ethereum', ticker: 'ETH', decimals: 18, - rpcTarget: 'https://rpc.ankr.com/eth', + rpcTarget: `https://api.web3auth.io/infura-service/v1/1/${clientId}`, blockExplorerUrl: 'https://etherscan.io', logo: 'https://cryptologos.cc/logos/ethereum-eth-logo.png', }; diff --git a/single-factor-auth-react-native/sfa-rn-expo-auth0-example/App.tsx b/single-factor-auth-react-native/sfa-rn-expo-auth0-example/App.tsx index 8f73e83c..69a6d7b9 100644 --- a/single-factor-auth-react-native/sfa-rn-expo-auth0-example/App.tsx +++ b/single-factor-auth-react-native/sfa-rn-expo-auth0-example/App.tsx @@ -29,7 +29,7 @@ const chainConfig = { tickerName: 'Ethereum', ticker: 'ETH', decimals: 18, - rpcTarget: 'https://rpc.ankr.com/eth', + rpcTarget: `https://api.web3auth.io/infura-service/v1/1/${clientId}`, blockExplorerUrl: 'https://etherscan.io', logo: 'https://cryptologos.cc/logos/ethereum-eth-logo.png', };