Skip to content

Commit 2942631

Browse files
committed
Update android SDK
1 parent d966333 commit 2942631

File tree

19 files changed

+1093
-703
lines changed

19 files changed

+1093
-703
lines changed

embedded-wallets/sdk/android/README.mdx

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Then, in your app-level `build.gradle` dependencies section, add the following:
4545
dependencies {
4646
// ...
4747
// focus-next-line
48-
implementation 'com.github.web3auth:web3auth-android-sdk:9.1.2'
48+
implementation 'com.github.web3auth:web3auth-android-sdk:10.0.0'
4949
}
5050
```
5151

@@ -148,14 +148,15 @@ Create a Web3Auth instance and configure it with your project settings:
148148
```kotlin
149149
import com.web3auth.core.Web3Auth
150150
import com.web3auth.core.types.Web3AuthOptions
151+
import org.torusresearch.fetchnodedetails.types.Web3AuthNetwork
151152

152153
// focus-start
153154
var web3Auth = Web3Auth(
154155
Web3AuthOptions(
155156
context = this,
156157
clientId = "YOUR_WEB3AUTH_CLIENT_ID", // Pass over your Web3Auth Client ID from Developer Dashboard
157-
network = Network.MAINNET,
158-
redirectUrl = Uri.parse("{YOUR_APP_PACKAGE_NAME}://auth"),
158+
web3AuthNetwork = Web3AuthNetwork.SAPPHIRE_MAINNET, // or Web3AuthNetwork.SAPPHIRE_DEVNET
159+
redirectUrl = "{YOUR_APP_PACKAGE_NAME}://auth",
159160
)
160161
)
161162
// focus-end
@@ -181,7 +182,7 @@ override fun onNewIntent(intent: Intent?) {
181182

182183
After instantiating Web3Auth, the next step is to initialize it using the `initialize` method. This method is essential for setting up the SDK, checking for any active sessions, and fetching the whitelabel configuration from your dashboard.
183184

184-
Once the `initialize` method executes successfully, you can use the `getPrivKey` or `getEd25519PrivKey` methods to verify if an active session exists. If there is no active session, these methods will return an empty string; otherwise, they will return the respective private key.
185+
Once the `initialize` method executes successfully, you can use the `getPrivateKey` or `getEd25519PrivateKey` methods to verify if an active session exists. If there is no active session, these methods will return an empty string; otherwise, they will return the respective private key.
185186

186187
:::note
187188

@@ -194,7 +195,7 @@ val initializeCF: CompletableFuture<Void> = web3Auth.initialize()
194195
initializeCF.whenComplete { _, error ->
195196
if (error == null) {
196197
// Check for the active session
197-
if(web3Auth.getPrivKey()isNotEmpty()) {
198+
if(web3Auth.getPrivateKey().isNotEmpty()) {
198199
// Active session found
199200
}
200201
// No active session is not present
@@ -235,7 +236,7 @@ val web3Auth = Web3Auth(
235236
Web3AuthOptions(
236237
context = this,
237238
clientId = "YOUR_CLIENT_ID",
238-
network = Network.SAPPHIRE_MAINNET, // or Network.SAPPHIRE_DEVNET
239+
web3AuthNetwork = Web3AuthNetwork.SAPPHIRE_MAINNET, // or Web3AuthNetwork.SAPPHIRE_DEVNET
239240
redirectUrl = "YOUR_APP_SCHEME://auth"
240241
)
241242
)
@@ -250,11 +251,11 @@ val web3Auth = Web3Auth(
250251
Web3AuthOptions(
251252
context = this,
252253
clientId = "YOUR_CLIENT_ID",
253-
network = Network.SAPPHIRE_MAINNET, // or Network.SAPPHIRE_DEVNET
254+
web3AuthNetwork = Web3AuthNetwork.SAPPHIRE_MAINNET, // or Web3AuthNetwork.SAPPHIRE_DEVNET
254255
redirectUrl = "YOUR_APP_SCHEME://auth"
255-
loginConfig = hashMapOf("google" to LoginConfigItem(
256-
verifier = "verifier-name", // Get it from Web3Auth dashboard
257-
typeOfLogin = TypeOfLogin.GOOGLE,
256+
authConnectionConfig = listOf(AuthConnectionConfig(
257+
authConnectionId = "auth-connection-id", // Get it from Web3Auth dashboard
258+
authConnection = AuthConnection.GOOGLE,
258259
clientId = getString(R.string.google_client_id) // Google's client id
259260
)),
260261
mfaSettings = MfaSettings(
@@ -273,13 +274,30 @@ val web3Auth = Web3Auth(
273274

274275
</Tabs>
275276

277+
## Single Factor Auth (SFA) Support
278+
279+
Web3Auth Android SDK includes built-in support for Single Factor Auth (SFA), allowing for seamless authentication when you already have a JWT token from your authentication system. When MFA is disabled, users won't even notice Web3Auth's presence - they'll be automatically authenticated using just your JWT token, making the login experience completely frictionless.
280+
281+
```kotlin
282+
// SFA login with custom JWT
283+
val loginCompletableFuture = web3Auth.connectTo(
284+
LoginParams(
285+
AuthConnection.CUSTOM,
286+
authConnectionId = "your_verifier_id",
287+
idToken = "your_jwt_token"
288+
)
289+
)
290+
```
291+
292+
SFA mode is automatically activated when you provide an `idToken` parameter. This enables direct authentication without additional social login steps, perfect for applications that already have their own authentication system.
293+
276294
## Blockchain Integration
277295

278296
Web3Auth is blockchain agnostic, enabling integration with any blockchain network. Out of the box, Web3Auth offers robust support for both **Solana** and **Ethereum**.
279297

280298
### Ethereum Integration
281299

282-
For Ethereum integration, you can get the private key using the `getPrivKey` method and use it with web3j or other Ethereum libraries:
300+
For Ethereum integration, you can get the private key using the `getPrivateKey` method and use it with web3j or other Ethereum libraries:
283301

284302
```kotlin
285303
import org.web3j.crypto.Credentials
@@ -288,7 +306,7 @@ import org.web3j.protocol.Web3j
288306
import org.web3j.protocol.http.HttpService
289307

290308
// Use your Web3Auth instance to get the private key
291-
val privateKey = web3Auth.getPrivKey()
309+
val privateKey = web3Auth.getPrivateKey()
292310

293311
// Generate the Credentials
294312
val credentials = Credentials.create(privateKey)
@@ -308,7 +326,7 @@ val ethBalance = BigDecimal.valueOf(balanceResponse.balance.toDouble()).divide(B
308326

309327
### Solana Integration
310328

311-
For Solana integration, you can get the Ed25519 private key using the `getEd25519PrivKey` method and use it with sol4k or any other Solana libraries:
329+
For Solana integration, you can get the Ed25519 private key using the `getEd25519PrivateKey` method and use it with sol4k or any other Solana libraries:
312330

313331
```kotlin
314332
import org.sol4k.Connection
@@ -317,7 +335,7 @@ import org.sol4k.Keypair
317335
val connection = Connection(RpcUrl.DEVNET)
318336

319337
// Use your Web3Auth instance to get the private key
320-
val ed25519PrivateKey = web3Auth.getEd25519PrivKey()
338+
val ed25519PrivateKey = web3Auth.getEd25519PrivateKey()
321339

322340
// Generate the Solana KeyPair
323341
val solanaKeyPair = Keypair.fromSecretKey(ed25519PrivateKey.hexToByteArray())

embedded-wallets/sdk/android/advanced/README.mdx

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@ When setting up Web3Auth, you'll pass in the options to the constructor. This co
1616
```kotlin
1717
import com.web3auth.core.Web3Auth
1818
import com.web3auth.core.types.Web3AuthOptions
19+
import org.torusresearch.fetchnodedetails.types.Web3AuthNetwork
1920

2021
// focus-start
2122
var web3Auth = Web3Auth(
2223
Web3AuthOptions(
2324
context = this,
2425
clientId = "YOUR_WEB3AUTH_CLIENT_ID", // Pass over your Web3Auth Client ID from Developer Dashboard
25-
network = Network.MAINNET,
26-
redirectUrl = Uri.parse("{YOUR_APP_PACKAGE_NAME}://auth"),
26+
web3AuthNetwork = Web3AuthNetwork.SAPPHIRE_MAINNET,
27+
redirectUrl = "{YOUR_APP_PACKAGE_NAME}://auth",
2728
)
2829
)
2930
// focus-end
@@ -50,21 +51,22 @@ The Web3Auth Constructor takes an object with `Web3AuthOptions` as input.
5051
| ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
5152
| `context` | Android context to launch Web-based authentication, usually is the current activity. It's a mandatory field, and accepts `android.content.Context` as a value. |
5253
| `clientId` | Your Web3Auth Client ID. You can get it from Web3Auth [Dashboard](https://dashboard.web3auth.io/) under project details. It's a mandatory field of type `String` |
53-
| `network` | Defines the Web3Auth Network. It's a mandatory field of type Network. |
54-
| `redirectUrl` | URL that Web3Auth will redirect API responses upon successful authentication from browser. It's a mandatory field of type `Uri`. |
54+
| `web3AuthNetwork` | Defines the Web3Auth Network. It's a mandatory field of type `Web3AuthNetwork`. |
55+
| `redirectUrl` | URL that Web3Auth will redirect API responses upon successful authentication from browser. It's a mandatory field of type `String`. |
5556
| `sessionTime?` | It allows developers to configure the session management time. Session Time is in seconds, default is 86400 seconds which is 1 day. `sessionTime` can be max 30 days |
56-
| `useCoreKitKey?` | Use CoreKit (or SFA) Key to get core kit key given by SFA SDKs. It's an optional field with default value as `false`. Useful for Wallet Pregeneration. |
57-
| `chainNamespace?` | Chain Namespace [`EIP155` and `SOLANA`]. It takes `ChainNamespace` as a value. |
57+
| `useSFAKey?` | Use SFA Key to get single factor auth key. It's an optional field with default value as `false`. Useful for Wallet Pregeneration and SFA mode. |
58+
| `chains?` | Custom chain configuration for blockchain networks. It takes `Chains` as a value. |
5859

5960
</TabItem>
6061

6162
<TabItem value="advanced">
6263

63-
| Parameter | Description |
64-
| -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
65-
| `whiteLabel?` | WhiteLabel options for web3auth. It helps you define custom UI, branding, and translations for your brand app. It takes `WhiteLabelData` as a value. |
66-
| `loginConfig?` | Login config for the custom verifiers. It takes `HashMap<String, LoginConfigItem>` as a value. |
67-
| `mfaSettings?` | Allows developers to configure the Mfa settings for authentication. It takes `MfaSettings` as a value. |
64+
| Parameter | Description |
65+
| ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
66+
| `whiteLabel?` | WhiteLabel options for web3auth. It helps you define custom UI, branding, and translations for your brand app. It takes `WhiteLabelData` as a value. |
67+
| `authConnectionConfig?` | Auth connection config for the custom auth connections. It takes `List<AuthConnectionConfig>` as a value. |
68+
| `mfaSettings?` | Allows developers to configure the MFA settings for authentication. It takes `MfaSettings` as a value. |
69+
| `walletServicesConfig?` | Configuration for wallet services including whitelabel options. It takes `WalletServicesConfig` as a value. |
6870

6971
</TabItem>
7072

@@ -74,16 +76,19 @@ The Web3Auth Constructor takes an object with `Web3AuthOptions` as input.
7476
data class Web3AuthOptions(
7577
var context: Context,
7678
val clientId: String,
77-
val network: Network,
78-
var buildEnv: BuildEnv? = BuildEnv.PRODUCTION,
79-
@Transient var redirectUrl: Uri,
80-
var sdkUrl: String = getSdkUrl(buildEnv),
79+
val web3AuthNetwork: Web3AuthNetwork,
80+
var authBuildEnv: BuildEnv? = BuildEnv.PRODUCTION,
81+
var redirectUrl: String,
82+
var sdkUrl: String = getSdkUrl(authBuildEnv),
8183
val whiteLabel: WhiteLabelData? = null,
82-
val loginConfig: HashMap<String, LoginConfigItem>? = null,
83-
val useCoreKitKey: Boolean? = false,
84-
val chainNamespace: ChainNamespace? = ChainNamespace.EIP155,
84+
val authConnectionConfig: List<AuthConnectionConfig>? = null,
85+
val useSFAKey: Boolean? = false,
86+
val chains: Chains? = null,
8587
val mfaSettings: MfaSettings? = null,
86-
val sessionTime: Int? = 86400
88+
val sessionTime: Int = 86400,
89+
val walletServicesConfig: WalletServicesConfig? = null,
90+
val defaultChainId: String? = null,
91+
val enableLogging: Boolean? = false
8792
)
8893
```
8994

@@ -106,9 +111,9 @@ var web3Auth = Web3Auth(
106111
Web3AuthOptions(
107112
context = this,
108113
clientId = "YOUR_WEB3AUTH_CLIENT_ID", // Pass over your Web3Auth Client ID from Developer Dashboard
109-
network = Network.MAINNET,
114+
web3AuthNetwork = Web3AuthNetwork.SAPPHIRE_MAINNET,
110115
sessionTime = 86400 * 7, // 7 days (in seconds)
111-
redirectUrl = Uri.parse("{YOUR_APP_PACKAGE_NAME}://auth"),
116+
redirectUrl = "{YOUR_APP_PACKAGE_NAME}://auth",
112117
)
113118
)
114119
```

0 commit comments

Comments
 (0)