Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
45 changes: 22 additions & 23 deletions embedded-wallets/authentication/custom-connections/auth0.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Auth0 Login with Embedded Wallets
title: Auth0 sign-in with Embedded Wallets
sidebar_label: Auth0
description: 'Auth0 Login with Embedded Wallets | Embedded Wallets'
description: 'Auth0 sign-in with Embedded Wallets | Embedded Wallets'
---

import Tabs from '@theme/Tabs'
Expand All @@ -17,7 +17,7 @@ import ImplicitLoginAuth0Spa from '../../sdk/react/advanced/_custom-authenticati

[Auth0](https://auth0.com/docs/get-started/auth0-overview) is an authentication and authorization platform that enables developers to securely manage user identities. Web3Auth offers native support for integrating Auth0 as a service provider, allowing projects to leverage Auth0's robust authentication mechanisms within the Web3Auth ecosystem.

Auth0 supports a [wide set of social logins](https://marketplace.auth0.com/categories/social-login).
Auth0 supports a [wide set of social sign-in providers](https://marketplace.auth0.com/categories/social-login).

## Create an Auth0 application

Expand All @@ -43,7 +43,7 @@ export const Auth0Setup = [
path: 'https://auth0.com/docs/quickstart/native/android/interactive',
},
{
key: 'ios',
key: 'iOS',
title: 'iOS',
icon: 'logo-apple.png',
path: 'https://auth0.com/docs/quickstart/native/ios-swift/interactive',
Expand Down Expand Up @@ -123,54 +123,53 @@ In your activity, create a `Web3Auth` instance with your Web3Auth project's conf
```kotlin
web3Auth = Web3Auth(
Web3AuthOptions(
context = this,
clientId = getString(R.string.web3auth_project_id), // pass over your Web3Auth Client ID from Embedded Wallets dashboard
network = Network.SAPPHIRE_MAINNET
redirectUrl = Uri.parse("{YOUR_APP_PACKAGE_NAME}://auth"), // your app's redirect URL
web3AuthNetwork = Web3AuthNetwork.SAPPHIRE_MAINNET,
redirectUrl = "{YOUR_APP_PACKAGE_NAME}://auth", // your app's redirect URL
// focus-start
loginConfig = hashMapOf("jwt" to LoginConfigItem(
verifier = "web3auth-auth0-demo",
typeOfLogin = TypeOfLogin.JWT,
name = "Auth0 Login",
authConnectionConfig = listOf(
AuthConnectionConfig(
authConnection = AuthConnection.CUSTOM,
authConnectionId = "web3auth-auth0-demo",
clientId = getString(R.string.web3auth_auth0_client_id)
)
)
)
// focus-end
)
),
this
)

// Handle user signing in when app is not alive
web3Auth.setResultUrl(intent?.data)
```

##### Logging in
##### Signing in

Once initialized, you can use the `web3Auth.login(LoginParams("{selectedLoginProvider}"))` function to authenticate the user when they click the login button.
Once initialized, you can use the `web3Auth.connectTo(LoginParams(...))` function to authenticate the user when they click the sign-in button.

```kotlin
private fun signIn() {
val selectedLoginProvider = Provider.JWT // For Auth0, we use JWT
val loginCompletableFuture: CompletableFuture<Web3AuthResponse> = web3Auth.login(
val loginCompletableFuture: CompletableFuture<Web3AuthResponse> = web3Auth.connectTo(
// focus-start
LoginParams(
selectedLoginProvider,
authConnection = AuthConnection.CUSTOM,
authConnectionId = "web3auth-auth0-demo",
extraLoginOptions = ExtraLoginOptions(
domain = "https://YOUR_AUTH0_DOMAIN",
verifierIdField = "sub"
domain = "https://YOUR_AUTH0_DOMAIN"
)
)
// focus-end
)
}
```

When connecting, the `login` function takes the LoginParams arguments for the login. See the [LoginParams](/embedded-wallets/sdk/android/usage/login#parameters) for more details.
When connecting, the `connectTo` function takes the `LoginParams` arguments for sign-in. See the [LoginParams](/embedded-wallets/sdk/android/usage/connect-to#parameters) for more details.

### Flutter

##### Create a Web3Auth instance

In your `main.dart` file, initialize the `Web3AuthFlutter` plugin at the very beginning such as in the overriden `initState` function
In your `main.dart` file, initialize the `Web3AuthFlutter` plugin at the start of your app, such as in the overridden `initState` function

```dart
Future<void> initPlatformState() async {
Expand Down Expand Up @@ -208,7 +207,7 @@ Future<void> initPlatformState() async {

##### Logging in

Once initialized, you can use the `Web3AuthFlutter.login(LoginParams( loginProvider: Provider.google ))` function to authenticate the user when they click the login button.
Once initialized, you can use the `Web3AuthFlutter.login(LoginParams( loginProvider: Provider.google ))` function to authenticate the user when they click the sign-in button.

```dart
Future<Web3AuthResponse> _withAuth0() {
Expand Down
58 changes: 30 additions & 28 deletions embedded-wallets/authentication/custom-connections/firebase.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Firebase Login with Embedded Wallets
title: Firebase sign-in with Embedded Wallets
sidebar_label: Firebase
description: 'Firebase Login with Embedded Wallets | Embedded Wallets'
description: 'Firebase sign-in with Embedded Wallets | Embedded Wallets'
---

import Tiles from '@theme/Tiles'
Expand All @@ -10,9 +10,9 @@ import CustomConnectionOptions from '@site/static/img/embedded-wallets/dev-dashb
import FirebaseConnection from '@site/static/img/embedded-wallets/dev-dashboard/firebase-connection.png'
import JwtLoginFirebase from '../../sdk/react/advanced/_custom-authentication-snippets/_jwt_login_firebase.mdx'

[Firebase](https://firebase.google.com/) is a popular backend platform that enables developers to integrate authentication, databases, and other services into their applications. Embedded Wallets supports Firebase as an authentication provider, allowing developers to leverage Firebase Authentication within the Web3Auth framework for secure user login and key management.
[Firebase](https://firebase.google.com/) is a popular backend platform that enables developers to integrate authentication, databases, and other services into their applications. Embedded Wallets supports Firebase as an authentication provider, allowing developers to leverage Firebase Authentication within the Web3Auth framework for secure user sign-in and key management.

Firebase [supports a wide set of social logins](https://firebase.google.com/docs/auth).
Firebase [supports a wide set of social sign-in providers](https://firebase.google.com/docs/auth).

## Create a Firebase project

Expand All @@ -25,6 +25,8 @@ Web3Auth's Firebase integration enables the use of Firebase-issued ID tokens to
For detailed implementation steps and platform-specific instructions, developers can follow the [Firebase documentation](https://firebase.google.com/docs).
:::

<!-- vale off -->

export const FirebaseSetup = [
{
name: '',
Expand All @@ -43,7 +45,7 @@ export const FirebaseSetup = [
path: 'https://firebase.google.com/docs/android/setup',
},
{
key: 'ios',
key: 'iOS',
title: 'iOS',
icon: 'logo-apple.png',
path: 'https://firebase.google.com/docs/ios/setup',
Expand All @@ -64,6 +66,8 @@ export const FirebaseSetup = [
},
]

<!-- vale on -->

<Tiles tileGroups={FirebaseSetup} />

## Create a Firebase connection
Expand All @@ -87,7 +91,7 @@ Follow these steps to create a Firebase connection:
1. Select the **JWT user identifier**: `email`, `sub` or `custom`.
1. (Optional) Toggle the case sensitivity of **User Identifier**.
1. Click on **Add Custom Validations** to add validations manually.
1. Type iss as a field and `https://securetoken.google.com/FIREBASE-PROJECT-ID` as a value.
1. Type `iss` as a field and `https://securetoken.google.com/FIREBASE-PROJECT-ID` as a value.
1. Next, type aud as a field and `FIREBASE-PROJECT-ID` as a value.
1. Click on the **Add Connection** button to save the settings.

Expand Down Expand Up @@ -116,29 +120,29 @@ In your activity, create a `Web3Auth` instance with your Web3Auth project's conf
```kotlin
web3Auth = Web3Auth(
Web3AuthOptions(
context = this,
clientId = getString(R.string.web3auth_project_id), // pass over your Web3Auth Client ID from Embedded Wallets dashboard
network = Network.SAPPHIRE_MAINNET
redirectUrl = Uri.parse("{YOUR_APP_PACKAGE_NAME}://auth"), // your app's redirect URL
web3AuthNetwork = Web3AuthNetwork.SAPPHIRE_MAINNET,
redirectUrl = "{YOUR_APP_PACKAGE_NAME}://auth", // your app's redirect URL
// focus-start
loginConfig = hashMapOf("jwt" to LoginConfigItem(
verifier = "web3auth-firebase-examples",
typeOfLogin = TypeOfLogin.JWT,
name = "Firebase Login",
authConnectionConfig = listOf(
AuthConnectionConfig(
authConnection = AuthConnection.CUSTOM,
authConnectionId = "web3auth-firebase-examples",
clientId = getString(R.string.web3auth_project_id)
)
)
)
// focus-end
)
),
this
)

// Handle user signing in when app is not alive
web3Auth.setResultUrl(intent?.data)
```

##### Logging in
##### Signing in

Once initialized, you can use the `web3Auth.login(LoginParams("{selectedLoginProvider}"))` function to authenticate the user when they click the login button.
Once initialized, you can use the `web3Auth.connectTo(LoginParams(...))` function to authenticate the user when they click the sign-in button.

```kotlin
private fun signIn() {
Expand All @@ -155,17 +159,15 @@ private fun signIn() {
val idToken = result.token

Log.d(TAG, "GetTokenResult result = $idToken")
val selectedLoginProvider = Provider.JWT
// focus-start
val loginCompletableFuture: CompletableFuture<Web3AuthResponse> = web3Auth.login(
val loginCompletableFuture: CompletableFuture<Web3AuthResponse> = web3Auth.connectTo(
LoginParams(
selectedLoginProvider,
extraLoginOptions = ExtraLoginOptions(
domain = "firebase", id_token = idToken
)
)
authConnection = AuthConnection.CUSTOM,
authConnectionId = "web3auth-firebase-examples",
idToken = idToken
)
// focus-end
)
// focus-end

loginCompletableFuture.whenComplete { loginResponse, error ->
if (error == null) {
Expand All @@ -187,13 +189,13 @@ private fun signIn() {
}
```

When connecting, the `login` function takes the LoginParams arguments for the login. See the [LoginParams](/embedded-wallets/sdk/android/usage/login#parameters) for more details.
When connecting, the `connectTo` function takes the `LoginParams` arguments for sign-in. See the [LoginParams](/embedded-wallets/sdk/android/usage/connect-to#parameters) for more details.

### Flutter

##### Create a Web3Auth instance

In your `main.dart` file, initialize the `Web3AuthFlutter` plugin at the very beginning such as in the overriden `initState` function
In your `main.dart` file, initialize the `Web3AuthFlutter` plugin at the start of your app, such as in the overridden `initState` function

```dart
@override
Expand Down Expand Up @@ -238,7 +240,7 @@ Future<void> initPlatformState() async {

##### Logging in

Once initialized, you can use the `Web3AuthFlutter.login(LoginParams( loginProvider: Provider.google ))` function to authenticate the user when they click the login button.
Once initialized, you can use the `Web3AuthFlutter.login(LoginParams( loginProvider: Provider.google ))` function to authenticate the user when they click the sign-in button.

```dart
Future<Web3AuthResponse> _withJWT() async {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Once user has successfully logged in, you can retrieve the user's private key using the `getPrivKey` method from the Embedded Wallets Android SDK. We'll use this private key to generate the Credentials for the user.
Once user has successfully logged in, you can retrieve the user's private key using the `getPrivateKey` method from the Embedded Wallets Android SDK. We'll use this private key to generate the Credentials for the user.

This Credentials object has the user's keypair of private key and public key, and can be used to sign the transactions. Please note, that this assumes that the user has already logged in and the private key is available.

```kotlin
import org.web3j.crypto.Credentials

// Use your Embedded Wallets SDK instance to get the private key
val privateKey = web3Auth.getPrivKey()
val privateKey = web3Auth.getPrivateKey()

// Generate the Credentials
val credentials = Credentials.create(privateKey)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ To interact with Ethereum in Android, you can use any [`EIP1193`](https://eips.e
```groovy
dependencies {
// ...
implementation 'org.web3j:core:4.8.7-android'
implementation 'org.web3j:core:4.8.8-android'
}
```
31 changes: 16 additions & 15 deletions embedded-wallets/connect-blockchain/solana/android.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ description: 'Integrate Embedded Wallets with the Solana Blockchain in Android |
import TabItem from '@theme/TabItem'
import Tabs from '@theme/Tabs'

While using the Embedded Wallets Android SDK (formerly Web3Auth), you can retrieve the Ed25519 private key upon successful authentication. This private key can be used to derive the user's public address and interact with the [Solana](https://solana.org/) chain. We've highlighted a few methods here to get you started quickly.
While using the Embedded Wallets Android SDK (formerly Web3Auth), you can retrieve the Ed25519 private key upon successful authentication. This private key can be used to derive the user's public address and interact with the [Solana](https://solana.org/) chain. We've highlighted a few methods here to help you get started.

::::note

Expand Down Expand Up @@ -77,7 +77,7 @@ In your app-level `build.gradle` dependencies section, add the following:
<Tabs defaultValue = "groovy"
values={[
{ label: "Groovy", value: "groovy", },
{ label: "Kotlin", value: "kotlin", },
{ label: "Kotlin DSL", value: "kotlin-dsl", },
]}
>

Expand All @@ -91,7 +91,7 @@ dependencies {

</TabItem>

<TabItem value="kotlin">
<TabItem value="kotlin-dsl">

```kotlin
dependencies {
Expand All @@ -104,7 +104,7 @@ dependencies {

## Initialize

To Initialize the `Connection` we require a RPC URL. The `Connection` object will provide a gateway and protocol to interact with Solana cluster while sending requests and receving response. The `sol4k` SDK also provides `RpcUrl` constant for all the supported clusters. For this example, we are using `RpcUrl.DEVNET` for Devnet-beta. To interact with Testnet or Mainnet, change the `RpcUrl`.
To Initialize the `Connection` we require a RPC URL. The `Connection` object will provide a gateway and protocol to interact with Solana cluster while sending requests and receiving responses. The `sol4k` SDK also provides `RpcUrl` constant for all the supported clusters. For this example, we are using `RpcUrl.DEVNET` for Devnet-beta. To interact with Testnet or Mainnet, change the `RpcUrl`.

### Initializing the Solana SDK

Expand All @@ -131,42 +131,43 @@ The session can be persisted for up to 30 days max.

```kotlin
import com.web3auth.core.Web3Auth
import com.web3auth.core.types.Network
import com.web3auth.core.types.Web3AuthOptions
import org.torusresearch.fetchnodedetails.types.Web3AuthNetwork

// Initialize Web3Auth SDK
// focus-start
val web3Auth: Web3Auth = Web3Auth(
Web3AuthOptions(
clientId = "BPi5PB_UiIZ-cPz1GtV5i1I2iOSOHuimiXBI0e-Oe_u6X3oVAbCiAZOTEBtTXw4tsluTITPqA8zMsfxIKMjiqNQ",
context = context,
network = Network.SAPPHIRE_MAINNET,
redirectUrl = Uri.parse( "com.example.androidsolanaexample://auth")
)
web3AuthNetwork = Web3AuthNetwork.SAPPHIRE_MAINNET,
redirectUrl = "com.example.androidsolanaexample://auth"
),
context
)
// focus-end

// Check whether private key is empty or not for user authentication status.
val isUserAuthenticated = web3Auth.getPrivkey().isNotEmpty()
val isUserAuthenticated = web3Auth.getEd25519PrivateKey().isNotEmpty()

// Customize your logic to perform operations or navigation
```

## Get account

We can use `getEd25519PrivKey` method in Web3Auth to retrieve the private key for the Solana ecosystem. In the following code block, we'll use the Ed25519 private key to retrieve user's public address by creating `Keypair`. The `Keypair` instance from `sol4k` SDK once created can be used to sign the Solana transactions.
We can use `getEd25519PrivateKey` method in Web3Auth to retrieve the private key for the Solana ecosystem. In the following code block, we'll use the Ed25519 private key to retrieve user's public address by creating `Keypair`. The `Keypair` instance from `sol4k` SDK once created can be used to sign the Solana transactions.

```kotlin
val ed25519PrivateKey = web3Auth.getEd25519PrivKey()
val ed25519PrivateKey = web3Auth.getEd25519PrivateKey()
val solanaKeyPair = Keypair.fromSecretKey(ed25519PrivateKey.hexToByteArray())

// focus-next-line
val userAccount = solanaKeyPair.publicKey.toBase58()
// Get the user's public key
val publicKey = solanaKeyPair.publicKey.toBase58()
```

## Get user balance

Once we have retrieved userAccount, we can use it to fetch user balance. We'll use `getBalance` method from `Connection` instance to interact with Solana cluster and fetch user balance. The response of `getBalance` is BigInteger, we will need to divide it by 10^9, because Solana's token decimals is 9.
Once you have the user's public key, you can use it to fetch the user balance. We'll use `getBalance` method from `Connection` instance to interact with Solana cluster and fetch user balance. The response of `getBalance` is BigInteger, we will need to divide it by 10^9, because Solana's token decimals is 9.

```kotlin
try {
Expand All @@ -186,7 +187,7 @@ try {

## Sign a transaction

Let's now go through how can we sign the transaction. In the below codeblock, we'll create a new function `prepareSignedTransaction` which can be used to retrieve the Base58 signature as well as broadcast transaction to the cluster. We'll use `TransferInstruction` to create the transaction to self transfer 0.01 Sol and sign it.
Let's now go through how can we sign the transaction. In the below code block, we'll create a new function `prepareSignedTransaction` which can be used to retrieve the Base58 signature as well as broadcast transaction to the cluster. We'll use `TransferInstruction` to create the transaction to self transfer 0.01 Sol and sign it.

```kotlin
private suspend fun prepareSignedTransaction(sender: Keypair) : Transaction = withContext(Dispatchers.IO) {
Expand Down
2 changes: 1 addition & 1 deletion embedded-wallets/migration-guides/README.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ current SDK in one pass.
| Platform | Upgrade to | Covers upgrades from |
| ---------------------------------------------------------------------- | ---------- | -------------------- |
| [Web (JavaScript, React, Vue)](/embedded-wallets/migration-guides/web) | v11 | v9 through v10 |
| [Android](/embedded-wallets/migration-guides/android) | v9 | v4 through v8 |
| [Android](/embedded-wallets/migration-guides/android) | v10 | v4 through v9 |
| [iOS](/embedded-wallets/migration-guides/ios) | v10 | v6 through v9 |
| [React Native](/embedded-wallets/migration-guides/react-native) | v9 | v3 through v8 |
| [Flutter](/embedded-wallets/migration-guides/flutter) | v6 | v3 through v5 |
Expand Down
Loading
Loading