Skip to content

Commit

Permalink
Merge pull request #531 from Web3Auth/pnp-android-v5.3
Browse files Browse the repository at this point in the history
Pnp android v5.3
  • Loading branch information
shahbaz17 authored Nov 14, 2023
2 parents 4fb689f + 568ce97 commit adee8e0
Show file tree
Hide file tree
Showing 5 changed files with 154 additions and 21 deletions.
2 changes: 1 addition & 1 deletion docs/sdk/pnp/android/android.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ authenticate users using Web3Auth. For using Web3Auth natively in Android, Web3A
key generated in a non-custodial way on successful user authentication. This authentication can be achieved by using any social login options that
Web3Auth supports or custom authentication flow of your choice.

#### This Documentation is based on the `5.1.1` SDK Version.
#### This Documentation is based on the `5.3.1` SDK Version.

## Requirements

Expand Down
70 changes: 61 additions & 9 deletions docs/sdk/pnp/android/initialize.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,27 @@ The Web3Auth Constructor takes an object with `Web3AuthOptions` as input.
| loginConfig | LoginConfigItem | No | A configuration optional object to use custom authentication. Refer [Custom Authentication](/pnp/features/custom-authentication) for more info. |
| useCoreKitKey | Boolean | No | Use Core Kit Key true to the Core Kit keys. |
| chainNamespace | enum com.web3auth.core.Web3Auth.ChainNamespace ["EIP155", "SOLANA"] | No | A configuration optional object to use chain namespace. |
| `mfaSettings` | MfaSettings | No | MFA Settings |
| `sessionTime` | `Int | No | Session Time in seconds, default is `86400` seconds |

</TabItem>

<TabItem value="interface">

```kotlin
data class Web3AuthOptions(
var context: Context,
val clientId: String,
val network: Network,
@Transient var redirectUrl: Uri? = null,
var sdkUrl: String = getSdkUrl(network),
val whiteLabel: WhiteLabelData? = null,
val loginConfig: HashMap<String, LoginConfigItem>? = null,
val useCoreKitKey: Boolean? = false,
val chainNamespace: ChainNamespace? = ChainNamespace.EIP155
var context: Context,
val clientId: String,
val network: Network,
var buildEnv: BuildEnv? = BuildEnv.PRODUCTION,
@Transient var redirectUrl: Uri? = null,
var sdkUrl: String = getSdkUrl(buildEnv),
val whiteLabel: WhiteLabelData? = null,
val loginConfig: HashMap<String, LoginConfigItem>? = null,
val useCoreKitKey: Boolean? = false,
val chainNamespace: ChainNamespace? = ChainNamespace.EIP155,
val mfaSettings: MfaSettings? = null,
val sessionTime: Int? = 86400
)
```

Expand Down Expand Up @@ -101,6 +106,53 @@ Add the below line to your `app/res/values/strings.xml` file:
</resources>
```

### Using the `mfaSettings` to configure MFA Order

You can configure the order of MFA or enable/disable MFA type by passing the `mfaSettings` object in `Web3AuthOptions`.

`MfaSettings`

<Tabs
defaultValue="table"
values={[
{ label: "Table", value: "table" },
{ label: "Class", value: "class" },
]}
>

<TabItem value="table">

`deviceShareFactor` | `backUpShareFactor` | `socialBackupFactor` | `passwordFactor`

| Parameter | Type | Mandatory | Description |
| ----------- | ------ | --------- | ---------------------- |
| `enable` | `bool` | Yes | Enable/Disable MFA |
| `priority` | `int` | No | Priority of MFA |
| `mandatory` | `bool` | No | Mandatory/Optional MFA |

</TabItem>

<TabItem value="class">

```kotlin
data class MfaSetting(
var enable: Boolean,
var priority: Int?,
var mandatory: Boolean?
)

data class MfaSettings(
private var deviceShareFactor: MfaSetting? = null,
private var backUpShareFactor: MfaSetting? = null,
private var socialBackupFactor: MfaSetting? = null,
private var passwordFactor: MfaSetting? = null,
)
```

</TabItem>

</Tabs>

### Session Management

The Session Management feature allows you to check the existing sessions with Web3Auth. The `sessionResponse()` will allow users to remain
Expand Down
2 changes: 1 addition & 1 deletion docs/sdk/pnp/android/install.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Then, in your app-level `build.gradle` dependencies section, add the following:
dependencies {
// ...
// highlight-next-line
implementation 'com.github.Web3Auth:web3auth-android-sdk:5.0.2'
implementation 'com.github.Web3Auth:web3auth-android-sdk:5.3.1'
}
```

Expand Down
81 changes: 81 additions & 0 deletions docs/sdk/pnp/android/mfa.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,84 @@ class MainActivity : AppCompatActivity() {
// ...
}
```

## Using the `mfaSettings` to configure MFA Order

You can configure the order of MFA or enable/disable MFA type by passing the `mfaSettings` object in `Web3AuthOptions`.

`MfaSettings`

<Tabs
defaultValue="table"
values={[
{ label: "Table", value: "table" },
{ label: "Class", value: "class" },
]}
>

<TabItem value="table">

`deviceShareFactor` | `backUpShareFactor` | `socialBackupFactor` | `passwordFactor`

| Parameter | Type | Mandatory | Description |
| ----------- | ------ | --------- | ---------------------- |
| `enable` | `bool` | Yes | Enable/Disable MFA |
| `priority` | `int` | No | Priority of MFA |
| `mandatory` | `bool` | No | Mandatory/Optional MFA |

</TabItem>

<TabItem value="class">

```kotlin
data class MfaSetting(
var enable: Boolean,
var priority: Int?,
var mandatory: Boolean?
)

data class MfaSettings(
private var deviceShareFactor: MfaSetting? = null,
private var backUpShareFactor: MfaSetting? = null,
private var socialBackupFactor: MfaSetting? = null,
private var passwordFactor: MfaSetting? = null,
)
```

</TabItem>

</Tabs>

```kotlin
web3Auth = Web3Auth(
Web3AuthOptions(
context = this,
clientId = getString(R.string.web3auth_project_id), // pass over your Web3Auth Client ID from Developer Dashboard
network = Network.SAPPHIRE_MAINNET, // pass over the network you want to use (MAINNET or TESTNET or CYAN, AQUA, SAPPHIRE_MAINNET or SAPPHIRE_TESTNET)
buildEnv = BuildEnv.PRODUCTION,
redirectUrl = Uri.parse("com.w3a.web3authdemoapp://auth"), // your app's redirect URL
// Optional parameters
whiteLabel = WhiteLabelData(
"Web3Auth Android FireBase Example",
null,
null,
null,
Language.EN,
ThemeModes.LIGHT,
true,
hashMapOf(
"primary" to "#eb5424"
)
),
// highlight-start
mfaSettings = MfaSettings(
deviceShareFactor = MfaSetting(true, 1, true),
socialBackupFactor = MfaSetting(true, 2, false),
passwordFactor = MfaSetting(true, 3, false),
backUpShareFactor = MfaSetting(true, 4, false),
)
// highlight-end
... // add your loginconfig
)
)
```
20 changes: 10 additions & 10 deletions docs/sdk/pnp/android/whitelabel.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ Object called `whiteLabel`. This parameter takes another object called `WhiteLab

<TabItem value="table">

| Parameter | Type | Mandatory | Description |
| ----------------- | ------------------ | --------- | --------------------------------------- |
| `appName` | `String` | No | Name of your application |
| `appUrl` | `String` | No | Url of your application |
| `logoLight` | `String` | No | Light logo for dark background |
| `logoDark` | `String` | No | Dark logo for light background |
| `defaultLanguage` | `String` | No | Default translation language to be used |
| `mode` | `Boolean` | No | 3 Theme modes of the application |
| `theme` | `Map<String, Any>` | No | Whitelabel theme |
| `useLogoLoader` | `Boolean` | No | Loads the logo when loading |
| Parameter | Type | Description | Default | Mandatory |
| ------------------ | ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------- | --------- |
| `appName?` | `string` | App name to be displayed in the User Flow Screens. | dApp's Website URL | No |
| `appUrl?` | `string` | App URL to be displayed in the User Flow Screens. | dApp's Website URL | No |
| `logoLight?` | `string` | App logo to be shown on the dark background (dark theme) | [web3auth-logo.svg](https://images.web3auth.io/web3auth-logo.svg) | No |
| `logoDark?` | `string` | App logo to be shown on the light background (light theme) | [web3auth-logo.svg](https://images.web3auth.io/web3auth-logo.svg) | No |
| `defaultLanguage?` | `string` | Default Language to use. <br/> Choose from: <ul><li>`Language.EN` - English</li><li>`Language.DE` - German</li><li>`Language.JA` - Japanese</li><li>`Language.KO` - Korean</li><li>`Language.ZH` - Mandarin</li><li>`Language.ES` - Spanish</li><li>`Language.FR` - French</li><li>`Language.PT` - Portuguese</li><li>`Language.NL` - Dutch</li></ul> | en - English | No |
| `mode?` | `string` | Choose between `auto`, `light` or `dark` modes. | `auto` | No |
| `theme?` | `Map<String, Any>` | Used to customize the theme of the login modal with the following options <br /> `'primary'` - To customize the primary color of the modal's content | `#0364FF` | No |
| `useLogoLoader` | `Boolean` | Loads the logo when loading | false | No |

</TabItem>

Expand Down

0 comments on commit adee8e0

Please sign in to comment.