Skip to content
Open
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
47 changes: 24 additions & 23 deletions embedded-wallets/authentication/custom-connections/auth0.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -173,51 +173,52 @@ In your `main.dart` file, initialize the `Web3AuthFlutter` plugin at the start o

```dart
Future<void> initPlatformState() async {

Uri redirectUrl;
late final String redirectUrl;
if (Platform.isAndroid) {
redirectUrl = Uri.parse('{SCHEME}://{HOST}/auth');
// w3a://com.example.w3aflutter/auth
redirectUrl = 'w3a://com.example.w3aflutter';
} else if (Platform.isIOS) {
redirectUrl = Uri.parse('{bundleId}://auth');
// com.example.w3aflutter://openlogin
redirectUrl = 'com.example.w3aflutter://openlogin';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We removed openlogin, auth was redirect changed we did when I joined, right?

} else {
throw UnKnownException('Unknown platform');
}
// focus-start
final loginConfig = HashMap<String, LoginConfigItem>();
loginConfig['jwt'] = LoginConfigItem(
verifier: "VERIFIER-NAME", // get it from MetaMask Developer Dashboard
typeOfLogin: TypeOfLogin.jwt,
name: "Web3Auth Flutter Auth0 Example",
clientId: "AUTH0-CLIENT-ID" // auth0 client id
);
final authConnectionConfig = [
AuthConnectionConfig(
authConnection: AuthConnection.custom,
authConnectionId: "VERIFIER-NAME",
clientId: "AUTH0-CLIENT-ID",
name: "Web3Auth Flutter Auth0 Example",
),
];
// focus-end

await Web3AuthFlutter.init(Web3AuthOptions(
clientId:'YOUR WEB3AUTH CLIENT ID FROM DASHBOARD',
network: Network.sapphire_mainnet,
redirectUri: redirectUrl,
loginConfig: loginConfig
clientId: 'YOUR WEB3AUTH CLIENT ID FROM DASHBOARD',
web3AuthNetwork: Web3AuthNetwork.sapphire_mainnet,
redirectUrl: redirectUrl,
authConnectionConfig: authConnectionConfig,
));

await Web3AuthFlutter.initialize();
}
```

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

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

```dart
Future<Web3AuthResponse> _withAuth0() {
// focus-start
return Web3AuthFlutter.login(LoginParams(
loginProvider: Provider.jwt,
return Web3AuthFlutter.connectTo(LoginParams(
authConnection: AuthConnection.custom,
authConnectionId: "VERIFIER-NAME",
mfaLevel: MFALevel.OPTIONAL,
extraLoginOptions: ExtraLoginOptions(
domain: 'YOUR_AUTH0_DOMAIN', // eg. https://torus.us.auth0.com
verifierIdField: 'sub')));
domain: 'YOUR_AUTH0_DOMAIN',
userIdField: 'sub',
),
));
// focus-end
}
```
Expand Down
52 changes: 25 additions & 27 deletions embedded-wallets/authentication/custom-connections/firebase.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -205,45 +205,45 @@ void initState() {
}

Future<void> initPlatformState() async {
final Uri redirectUrl;
late final String redirectUrl;
if (Platform.isAndroid) {
redirectUrl = Uri.parse('{SCHEME}://{HOST}/auth');
redirectUrl = 'w3a://com.example.w3aflutter';
} else if (Platform.isIOS) {
redirectUrl = Uri.parse('{bundleId}://auth');
redirectUrl = 'com.example.w3aflutter://openlogin';
} else {
throw UnKnownException('Unknown platform');
}

// focus-start
final loginConfig = HashMap<String, LoginConfigItem>();

loginConfig['jwt'] = LoginConfigItem(
verifier: "VERIFIER_NAME", // get it from MetaMask Developer Dashboard
typeOfLogin: TypeOfLogin.jwt,
name: "Firebase JWT Login",
clientId: "WEB3AUTH_CLIENT_ID", // web3auth's plug and play client id
);
final authConnectionConfig = [
AuthConnectionConfig(
authConnection: AuthConnection.custom,
authConnectionId: "VERIFIER_NAME",
clientId: "WEB3AUTH_CLIENT_ID",
name: "Firebase JWT Login",
),
];

await Web3AuthFlutter.init(
Web3AuthOptions(
clientId:'YOUR WEB3AUTH CLIENT ID FROM DASHBOARD',
network: Network.cyan,
redirectUri: redirectUrl,
loginConfig: loginConfig,
)
clientId: 'YOUR WEB3AUTH CLIENT ID FROM DASHBOARD',
web3AuthNetwork: Web3AuthNetwork.sapphire_mainnet,
redirectUrl: redirectUrl,
authConnectionConfig: authConnectionConfig,
),
);
// focus-end
// focus-end

await Web3AuthFlutter.initialize();
}
```

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

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

```dart
Future<Web3AuthResponse> _withJWT() async {
Future<Web3AuthResponse> _loginWithFirebase() async {
String idToken = "";
try {
// focus-start
Expand All @@ -263,16 +263,14 @@ Future<Web3AuthResponse> _withJWT() async {
}

// focus-start
return Web3AuthFlutter.login(
return Web3AuthFlutter.connectTo(
LoginParams(
loginProvider: Provider.jwt,
extraLoginOptions: ExtraLoginOptions(
id_token: idToken,
domain: 'firebase',
),
authConnection: AuthConnection.custom,
authConnectionId: "VERIFIER_NAME",
idToken: idToken,
),
);
// focus-end
// focus-end
}
```

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Once the user has successfully logged in, you can retrieve the user's private key using the `getPrivKey` method from the Embedded Wallets Flutter SDK. We'll use this private key to generate the Credentials for the user.
Once the user has successfully signed in, you can retrieve the user's private key using the `getPrivateKey` method from the Embedded Wallets Flutter 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.
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 signed in and the private key is available.

```dart
import 'package:web3dart/web3dart.dart';

final privateKey = await Web3AuthFlutter.getPrivKey();
final privateKey = await Web3AuthFlutter.getPrivateKey();

final credentials = EthPrivateKey.fromHex(privateKey);
final address = credentials.address;
Expand Down
14 changes: 7 additions & 7 deletions embedded-wallets/connect-blockchain/solana/flutter.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -156,19 +156,19 @@ Future<void> main() async {
// Initialize ServiceLocator
ServiceLocator.init();

final Uri redirectUrl;
late final String redirectUrl;
if (Platform.isAndroid) {
redirectUrl = Uri.parse('w3aexample://com.example.flutter_solana_example/auth');
redirectUrl = 'w3aexample://com.example.flutter_solana_example';
} else {
redirectUrl = Uri.parse('com.web3auth.fluttersolanasample://auth');
redirectUrl = 'com.web3auth.fluttersolanasample://auth';
}

// focus-start
await Web3AuthFlutter.init(
Web3AuthOptions(
clientId:
"BHgArYmWwSeq21czpcarYh0EVq2WWOzflX-NTK-tY1-1pauPzHKRRLgpABkmYiIV_og9jAvoIxQ8L3Smrwe04Lw",
network: Network.sapphire_devnet,
web3AuthNetwork: Web3AuthNetwork.sapphire_devnet,
redirectUrl: redirectUrl,
),
);
Expand All @@ -190,7 +190,7 @@ class _MainAppState extends State<MainApp> {
@override
void initState() {
super.initState();
privateKeyFuture = Web3AuthFlutter.getEd25519PrivKey();
privateKeyFuture = Web3AuthFlutter.getEd25519PrivateKey();
}

@override
Expand Down Expand Up @@ -224,7 +224,7 @@ class _MainAppState extends State<MainApp> {

## Get account and Balance

We can use `getEd25519PrivKey` method in Web3Auth to retrive the priavte key for the Solana ecosystem.
We can use `getEd25519PrivateKey` method in Web3Auth to retrive the priavte key for the Solana ecosystem.
In the following code block, we'll use the Ed25519 private key to retive user's public address, and
Solana balance. We'll use `SolanaProvider` class to interact with Solana cluster and fetch user
balance.
Expand Down Expand Up @@ -288,7 +288,7 @@ class _HomeScreenState extends State<HomeScreen> {

Future<void> loadAccount(BuildContext context) async {
try {
final privateKey = await Web3AuthFlutter.getEd25519PrivKey();
final privateKey = await Web3AuthFlutter.getEd25519PrivateKey();

// ..
// Additional code
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 @@ -34,7 +34,7 @@ current SDK in one pass.
| [Android](/embedded-wallets/migration-guides/android) | v9 | v4 through v8 |
| [iOS](/embedded-wallets/migration-guides/ios) | v12 | v6 through v11 |
| [React Native](/embedded-wallets/migration-guides/react-native) | v9 | v3 through v8 |
| [Flutter](/embedded-wallets/migration-guides/flutter) | v6 | v3 through v5 |
| [Flutter](/embedded-wallets/migration-guides/flutter) | v7 | v3 through v6 |

Each guide includes install steps, breaking changes grouped by version, a summary table, and
platform-specific release notes.
Expand Down
Loading
Loading