From 5fc63d1fd427828ca4f676b6e94385b813a3d134 Mon Sep 17 00:00:00 2001 From: hqjang-pepper Date: Mon, 6 Nov 2023 11:17:36 +0900 Subject: [PATCH 1/3] pnp swift v7 docs update --- docs/pnp/migration-guides/ios-v6-to-v7.mdx | 153 +++++++++++++++++++++ docs/sdk/pnp/ios/initialize.mdx | 5 +- docs/sdk/pnp/ios/install.mdx | 4 +- docs/sdk/pnp/ios/ios.mdx | 2 +- docs/sdk/pnp/ios/mfa.mdx | 18 +-- docs/sdk/pnp/ios/whitelabel.mdx | 32 +++-- sidebars.js | 7 + 7 files changed, 194 insertions(+), 27 deletions(-) create mode 100644 docs/pnp/migration-guides/ios-v6-to-v7.mdx diff --git a/docs/pnp/migration-guides/ios-v6-to-v7.mdx b/docs/pnp/migration-guides/ios-v6-to-v7.mdx new file mode 100644 index 000000000..b147a5153 --- /dev/null +++ b/docs/pnp/migration-guides/ios-v6-to-v7.mdx @@ -0,0 +1,153 @@ +--- +title: PnP IOS SDK - v6 to v7 +displayed_sidebar: docs +description: "PnP IOS SDK - v6 to v7 | Documentation - Web3Auth" +sidebar_label: v6 to v7 +--- + +import TabItem from "@theme/TabItem"; +import Tabs from "@theme/Tabs"; + +## General + +### openlogin v5 is supported + +With V7, Users can now log in from sapphire mainnet and sapphire devnet. + +```swift +import Web3Auth + +let web3auth = Web3Auth(W3AInitParams( + clientId: "", + network: .MAINNET, // you can use .sapphire_devnet or .sapphire_mainnet + sdkUrl: ..., + redirectUrl: ..., +)) +``` + +### Web3AuthState now has more parameters + +In v7, you should add `coreKitKey` and `coreKitEd25519PrivKey` field when you initialize Web3authState. + +```swift +let user: Web3AuthState = .init(privKey: "12345", + ed25519PrivKey: "32334", + sessionId: "23234384y7735y47shdj", + userInfo: nil, + error: nil, + // highlight-start + coreKitKey: "45676", + coreKitEd25519PrivKey: "84567" + // highlight-end +) +``` + +### W3AInitParams param configuration changed + +In v7, the whiteLabel parameter type and configuration has changed. And, as mentioned earlier, the sapphire network type has been added. Also several +parameters have been added to W3AInitParams. + +#### change of `WhiteLabel` parameter configuration + + + + + +| Parameter | Type | Mandatory | Description | +| ----------------- | ------------------ | --------- | ------------------------------------------------- | +| `name` | `String` | No | Name 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 | +| `dark` | `Boolean` | No | If true, enables dark mode. Default is light mode | +| `theme` | `[String, String]` | No | Whitelabel theme | + + + + + +| Parameter | Type | Mandatory | Description | +| ----------------- | ------------------ | --------- | --------------------------------------- | +| `appName` | `String` | No | Name 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` | `Bool` | No | 3 Theme modes of the application | +| `theme` | `[String, String]` | No | Whitelabel theme | +| `appUrl` | `String` | No | Url of your application | +| `useLogoLoader` | `Bool` | No | Loads the logo when loading | + + + + + +#### change of `W3AInitParams` object + +The `Web3Auth` constructor takes an object called `W3AInitParams` as input. The below are the aviliable fields of the `W3AInitParams` object. + + + + + +| Parameter | Type | Mandatory | Description | +| ---------------- | --------------------------- | --------- | --------------------------------------------------------------------------------------------------------------------------------------------- | +| `clientId` | String | Yes | Your Web3Auth project ID | +| `network` | Network | Yes | Web3Auth Network to run the authentication on, either `.mainnet`,`.aqua`, `.testnet` or `.cyan` | +| `sdkUrl` | URL | No | Web3Auth sdk frontend to be used. This field is for advanced usage only and should not be changed. | +| `redirectUrl` | String | No | redirectUrl to be passed to the sdk frontend. This field is for advanced usage only and should not be changed. | +| `whiteLabel` | W3AWhiteLabelData | No | A configuration optional object to customize UI, branding, and translations for your brand. Refer to the WhiteLabeling section for more info. | +| `loginConfig` | `[String : W3ALoginConfig]` | No | A configuration optional object to customize login flow. | +| `useCoreKitKey` | `bool` | No | Use CoreKit Key to get core kit key. | +| `chainNamespace` | `ChainNamespace` | No | Chain Namespace [`eip155` and `solana`] | + + + + + +| Parameter | Type | Mandatory | Description | +| ---------------- | --------------------------- | --------- | --------------------------------------------------------------------------------------------------------------------------------------------- | +| `clientId` | String | Yes | Your Web3Auth project ID | +| `network` | Network | Yes | Web3Auth Network to run the authentication on, either `.mainnet`,`.aqua`, `.testnet`, `.cyan`, or `.sapphire_devnet` or `.sapphire_mainnet` | +| `buildEnv` | BuildEnv | No | Obtion for auth service, `production`, `staging`, `testing` available | +| `sdkUrl` | URL | No | Web3Auth sdk frontend to be used. This field is for advanced usage only and should not be changed. | +| `redirectUrl` | String | No | redirectUrl to be passed to the sdk frontend. This field is for advanced usage only and should not be changed. | +| `whiteLabel` | W3AWhiteLabelData | No | A configuration optional object to customize UI, branding, and translations for your brand. Refer to the WhiteLabeling section for more info. | +| `loginConfig` | `[String : W3ALoginConfig]` | No | A configuration optional object to customize login flow. | +| `useCoreKitKey` | `bool` | No | Use CoreKit Key to get core kit key. | +| `chainNamespace` | `ChainNamespace` | No | Chain Namespace [`eip155` and `solana`] | +| `MfaSettings` | `MfaSettings` | No | Settings for Multi factor authentication | +| `sessionTIme` | Int | No | Session maintainance time | + + + + + +Here's the example configuration of Web3AuthOptions. + +```swift +web3Auth = await Web3Auth(W3AInitParams( + clientId: clientId, + network: network, + whiteLabel: W3AWhiteLabelData( + appName: "Web3Auth iOS Example", + defaultLanguage: .en, + mode: .dark, theme: ["primary": "#123456"]) + )) +``` + +### web3.swift version updated to v1.6 + +With V7, lots of package dependencies have been updated. Among that, version of package `web3.swift` is updated to v1.6.0. Ethereum-related calls from +the client changed lot, so need to care about that. diff --git a/docs/sdk/pnp/ios/initialize.mdx b/docs/sdk/pnp/ios/initialize.mdx index 6d9f25528..e538345b8 100644 --- a/docs/sdk/pnp/ios/initialize.mdx +++ b/docs/sdk/pnp/ios/initialize.mdx @@ -62,10 +62,13 @@ The `Web3Auth` constructor takes an object called `W3AInitParams` as input. The | Parameter | Type | Mandatory | Description | | ---------------- | --------------------------- | --------- | --------------------------------------------------------------------------------------------------------------------------------------------- | | `clientId` | String | Yes | Your Web3Auth project ID | -| `network` | Network | Yes | Web3Auth Network to run the authentication on, either `.mainnet`,`.aqua`, `.testnet` or `.cyan` | +| `network` | Network | Yes | Web3Auth Network to run the authentication on, either `.mainnet`,`.aqua`, `.testnet`, `.cyan`, or `.sapphire_devnet` or `.sapphire_mainnet` | +| `buildEnv` | BuildEnv | No | Obtion for auth service, `production`, `staging`, `testing` available | | `sdkUrl` | URL | No | Web3Auth sdk frontend to be used. This field is for advanced usage only and should not be changed. | | `redirectUrl` | String | No | redirectUrl to be passed to the sdk frontend. This field is for advanced usage only and should not be changed. | | `whiteLabel` | W3AWhiteLabelData | No | A configuration optional object to customize UI, branding, and translations for your brand. Refer to the WhiteLabeling section for more info. | | `loginConfig` | `[String : W3ALoginConfig]` | No | A configuration optional object to customize login flow. | | `useCoreKitKey` | `bool` | No | Use CoreKit Key to get core kit key. | | `chainNamespace` | `ChainNamespace` | No | Chain Namespace [`eip155` and `solana`] | +| `MfaSettings` | `MfaSettings` | No | Settings for Multi factor authentication | +| `sessionTIme` | Int | No | Session maintainance time | diff --git a/docs/sdk/pnp/ios/install.mdx b/docs/sdk/pnp/ios/install.mdx index 68bc690c6..4b3549d33 100644 --- a/docs/sdk/pnp/ios/install.mdx +++ b/docs/sdk/pnp/ios/install.mdx @@ -17,14 +17,14 @@ description: "Installing Web3Auth PnP iOS SDK | Documentation - Web3Auth" https://github.com/Web3Auth/web3auth-swift-sdk ``` - From the `Dependency Rule` dropdown, select `Exact Version` and enter `6.0.1` as the version. + From the `Dependency Rule` dropdown, select `Exact Version` and enter `7.3.0` as the version. 1. When finished, Xcode will automatically begin resolving and downloading your dependencies in the background. ## Cocoapods ```sh -pod 'Web3Auth', '~> 6.0.1' +pod 'Web3Auth', '~> 7.2.0' ``` ## Configuration diff --git a/docs/sdk/pnp/ios/ios.mdx b/docs/sdk/pnp/ios/ios.mdx index 599794a3c..887325dbe 100644 --- a/docs/sdk/pnp/ios/ios.mdx +++ b/docs/sdk/pnp/ios/ios.mdx @@ -10,7 +10,7 @@ iOS SDK is a client-side library you can use with your iOS app to authenticate u custodial way on successful authentication of the user. This authentication can be achieved by using any of the social logins Web3Auth provides or using a custom authentication flow of your choice. -#### This Documentation is based on the `6.0.1` SDK Version. +#### This Documentation is based on the `7.3.0` SDK Version. ### Requirements diff --git a/docs/sdk/pnp/ios/mfa.mdx b/docs/sdk/pnp/ios/mfa.mdx index 2bd7162ff..4e8f99646 100644 --- a/docs/sdk/pnp/ios/mfa.mdx +++ b/docs/sdk/pnp/ios/mfa.mdx @@ -10,12 +10,6 @@ device and also to recover their account if they lose their original device. You can set the mfaLevel within the `loginParams` to customize when mfa screen should be shown to user. It currently accepts 4 values: -- **`default`** - Setting the mfaLevel to default will present the MFA screen to user on every third login. `mfaLevel = MFALevel.DEFAULT` -- **`optional`** - Setting mfaLevel to optional will present the MFA screen to user on every login but user will have the option to skip it. - `mfaLevel = MFALevel.OPTIONAL` -- **`mandatory`** - Setting mfaLevel to mandatory will make it mandatory for user to setup MFA after login. `mfaLevel = MFALevel.MANDATORY` -- **`none`** - Setting mfaLevel to none will skip the mfa setup screen totally. `mfaLevel = MFALevel.NONE` - ```swift Web3Auth().login(W3ALoginParams(loginProvider: provider, mfaLevel = MFALevel.MANDATORY)) ``` @@ -54,9 +48,15 @@ class ViewModel: ObservableObject { let result = try await Web3Auth().login( W3ALoginParams( loginProvider: provider, // can be .GOOGLE, .FACEBOOK, .APPLE etc - // highlight-next-line - mfaLevel: MFALevel.MANDATORY - )) + // highlight-start + mfaSettings: MfaSettings( + deviceShareFactor: .init(enable: true, priority: 1), + backUpShareFactor: .init(enable: true, priority: 2), + socialBackupFactor: .init(enable: true, priority: 3), + passwordFactor: .init(enable: true, priority: 4) + ) + // highlight-end + )) await MainActor.run(body: { user = result loggedIn = true diff --git a/docs/sdk/pnp/ios/whitelabel.mdx b/docs/sdk/pnp/ios/whitelabel.mdx index 824af1ff8..03651e930 100644 --- a/docs/sdk/pnp/ios/whitelabel.mdx +++ b/docs/sdk/pnp/ios/whitelabel.mdx @@ -25,14 +25,16 @@ For defining custom UI, branding, and translations for your brand app, you just -| Parameter | Type | Mandatory | Description | -| ----------------- | ------------------ | --------- | ------------------------------------------------- | -| `name` | `String` | No | Name 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 used | -| `dark` | `Bool` | No | If true, enables dark mode. Default is light mode | -| `theme` | `[String, String]` | No | Whitelabel theme | +| Parameter | Type | Mandatory | Description | +| ----------------- | ------------------ | --------- | --------------------------------------- | +| `appName` | `String` | No | Name 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` | `Bool` | No | 3 Theme modes of the application | +| `theme` | `[String, String]` | No | Whitelabel theme | +| `appUrl` | `String` | No | Url of your application | +| `useLogoLoader` | `Bool` | No | Loads the logo when loading | @@ -40,12 +42,14 @@ For defining custom UI, branding, and translations for your brand app, you just ```swift public struct W3AWhiteLabelData: Codable { - let name: String? + let appName: String? let logoLight: String? let logoDark: String? - let defaultLanguage: String? - let dark: Bool? + let defaultLanguage: Language? + let mode: ThemeModes? let theme: [String: String]? + let appUrl: String? + let useLogoLoader: Bool? } ``` @@ -60,11 +64,11 @@ web3Auth = await Web3Auth( network: .testnet, // highlight-start whiteLabel: W3AWhiteLabelData( - name: "Web3Auth Stub", + appName: "Web3Auth Stub", logoLight: "https://images.web3auth.io/web3auth-logo-w.svg", logoDark: "https://images.web3auth.io/web3auth-logo-w.svg", - defaultLanguage: "en", // en, de, ja, ko, zh, es, fr, pt, nl - dark: true, + defaultLanguage: .en, // en, de, ja, ko, zh, es, fr, pt, nl + mode: .dark theme: ["primary": "#d53f8c"]) )) // highlight-end diff --git a/sidebars.js b/sidebars.js index e5200732e..6ac6ea687 100644 --- a/sidebars.js +++ b/sidebars.js @@ -128,6 +128,13 @@ module.exports = { collapsible: true, items: ["pnp/migration-guides/android-v4-to-v5"], }, + { + type: "category", + label: "PnP IOS", + collapsed: true, + collapsible: true, + items: ["pnp/migration-guides/ios-v6-to-v7"], + }, "pnp/migration-guides/rn-v3-to-v4", ], From 423d6e8f23316952a8b25f1a6e075dd82b28c4f3 Mon Sep 17 00:00:00 2001 From: hqjang-pepper Date: Fri, 10 Nov 2023 19:53:11 +0900 Subject: [PATCH 2/3] add more explanation & v7.4 updates --- docs/pnp/migration-guides/ios-v6-to-v7.mdx | 169 ++++++++++++++++++--- docs/sdk/pnp/ios/custom-authentication.mdx | 1 + docs/sdk/pnp/ios/install.mdx | 4 +- docs/sdk/pnp/ios/ios.mdx | 2 +- docs/sdk/pnp/ios/mfa.mdx | 118 ++++++++++++-- docs/sdk/pnp/ios/whitelabel.mdx | 20 +-- 6 files changed, 275 insertions(+), 39 deletions(-) diff --git a/docs/pnp/migration-guides/ios-v6-to-v7.mdx b/docs/pnp/migration-guides/ios-v6-to-v7.mdx index b147a5153..80a6e9904 100644 --- a/docs/pnp/migration-guides/ios-v6-to-v7.mdx +++ b/docs/pnp/migration-guides/ios-v6-to-v7.mdx @@ -12,7 +12,7 @@ import Tabs from "@theme/Tabs"; ### openlogin v5 is supported -With V7, Users can now log in from sapphire mainnet and sapphire devnet. +With V7, Users can now log in from `Sapphire Mainnet` and `Sapphire Devnet`. ```swift import Web3Auth @@ -25,9 +25,9 @@ let web3auth = Web3Auth(W3AInitParams( )) ``` -### Web3AuthState now has more parameters +### `Web3AuthState` now has more parameters -In v7, you should add `coreKitKey` and `coreKitEd25519PrivKey` field when you initialize Web3authState. +In v7, you should add `coreKitKey` and `coreKitEd25519PrivKey` field when you initialize `Web3authState`. ```swift let user: Web3AuthState = .init(privKey: "12345", @@ -42,10 +42,10 @@ let user: Web3AuthState = .init(privKey: "12345", ) ``` -### W3AInitParams param configuration changed +### `W3AInitParams` param configuration changed In v7, the whiteLabel parameter type and configuration has changed. And, as mentioned earlier, the sapphire network type has been added. Also several -parameters have been added to W3AInitParams. +parameters have been added to `W3AInitParams`. #### change of `WhiteLabel` parameter configuration @@ -86,10 +86,10 @@ parameters have been added to W3AInitParams. - #### change of `W3AInitParams` object -The `Web3Auth` constructor takes an object called `W3AInitParams` as input. The below are the aviliable fields of the `W3AInitParams` object. +The `Web3Auth` constructor takes an object called `W3AInitParams` as input. The below are the aviliable fields of the `W3AInitParams` object. With v7, +additional 2 parameters, which are `MfaSettings` and `sessionTIme` can be set. -Here's the example configuration of Web3AuthOptions. +Here's the example configuration of `Web3AuthOptions`. ```swift -web3Auth = await Web3Auth(W3AInitParams( - clientId: clientId, - network: network, - whiteLabel: W3AWhiteLabelData( - appName: "Web3Auth iOS Example", - defaultLanguage: .en, - mode: .dark, theme: ["primary": "#123456"]) - )) + let result = try await Web3Auth(.init( + clientId: clientId, + network: network, + loginConfig: [ + TypeOfLogin.google.rawValue: + .init( + verifier: "w3a-agg-example", + typeOfLogin: .google, + name: "Web3Auth-Aggregate-Verifier-Google-Example", + clientId: "774338308167-q463s7kpvja16l4l0kko3nb925ikds2p.apps.googleusercontent.com", + verifierSubIdentifier: "w3a-google" + ) + ], + whiteLabel: W3AWhiteLabelData( + appName: "Web3Auth Stub", + logoLight: "https://images.web3auth.io/web3auth-logo-w.svg", + logoDark: "https://images.web3auth.io/web3auth-logo-w.svg", + defaultLanguage: .en, // en, de, ja, ko, zh, es, fr, pt, nl + mode: .dark, + theme: ["primary": "#d53f8c"]), + mfaSettings: MfaSettings( + deviceShareFactor: MfaSetting(enable: true, priority: 1), + backUpShareFactor: MfaSetting(enable: true, priority: 2), + socialBackupFactor: MfaSetting(enable: true, priority: 3), + passwordFactor: MfaSetting(enable: true, priority: 4) + ) + )).login( + W3ALoginParams( + loginProvider: .GOOGLE, + dappShare: nil, + extraLoginOptions: ExtraLoginOptions(display: nil, prompt: nil, max_age: nil, ui_locales: nil, id_token_hint: nil, id_token: nil, login_hint: nil, acr_values: nil, scope: nil, audience: nil, connection: nil, domain: nil, client_id: nil, redirect_uri: nil, leeway: nil, verifierIdField: nil, isVerifierIdCaseSensitive: nil, additionalParams: nil), + mfaLevel: .DEFAULT, + curve: .SECP256K1 + )) ``` -### web3.swift version updated to v1.6 +### 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` + + + + + +`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 | + + + + + +```swift + + public struct MfaSetting: Codable { + public init(enable: Bool, priority: Int?, mandatory: Bool? = nil) { + self.enable = enable + self.priority = priority + self.mandatory = mandatory + } + + let enable: Bool + let priority: Int? + let mandatory: Bool? + } + + public struct MfaSettings: Codable { + public init(deviceShareFactor: MfaSetting?, backUpShareFactor: MfaSetting?, socialBackupFactor: MfaSetting?, passwordFactor: MfaSetting?) { + self.deviceShareFactor = deviceShareFactor + self.backUpShareFactor = backUpShareFactor + self.socialBackupFactor = socialBackupFactor + self.passwordFactor = passwordFactor + } + + let deviceShareFactor: MfaSetting? + let backUpShareFactor: MfaSetting? + let socialBackupFactor: MfaSetting? + let passwordFactor: MfaSetting? + } + + +``` + + + + + +### `web3.swift` version updated to v1.6 With V7, lots of package dependencies have been updated. Among that, version of package `web3.swift` is updated to v1.6.0. Ethereum-related calls from the client changed lot, so need to care about that. + +### ExtraLoginOptions + +With V7, ExtraLoginOptions now has one more parameter which is `additionalParams: [String : String]?` + + + +| Parameter | Type | Description | +| --------------------------- | --------- | -------------------------------------------------------------------------------------------------------------------------------------------- | +| `domain` | `string` | Your Auth0 account domain such as `example.auth0.com` or `example.mycompany.com` etc. **Use any random string in case of custom JWT login.** | +| `client_id` | `string` | The Client ID found on your Auth0 Application settings page. **Use web3auth client id in case of custom JWT login.** | +| `redirect_uri` | `string` | The default URL where Auth0 will redirect your browser to with the authentication result. | +| `leeway` | `number` | The value in seconds used to account for clock skew in JWT expirations. | +| `verifierIdField` | `string` | The field in jwt token which maps to verifier id. | +| `isVerifierIdCaseSensitive` | `boolean` | Whether the verifier id field is case sensitive. Defaults to `true` | + + + + + +```swift +public struct ExtraLoginOptions: Codable{ + let display: String? + let prompt: String? + let max_age: String? + let ui_locales: String? + let id_token_hint: String? + let id_token: String? + let login_hint: String? + let acr_values: String? + let scope: String? + let audience: String? + let connection: String? + let domain: String? + let client_id: String? + let redirect_uri: String? + let leeway: Int? + let verifierIdField: String? + let isVerifierIdCaseSensitive: Bool? + // highlight-start + let additionalParams: [String : String]? + // highlight-end +} +``` + + diff --git a/docs/sdk/pnp/ios/custom-authentication.mdx b/docs/sdk/pnp/ios/custom-authentication.mdx index 764af5ded..19fb193b4 100644 --- a/docs/sdk/pnp/ios/custom-authentication.mdx +++ b/docs/sdk/pnp/ios/custom-authentication.mdx @@ -232,6 +232,7 @@ public struct ExtraLoginOptions: Codable{ let leeway: Int? let verifierIdField: String? let isVerifierIdCaseSensitive: Bool? + let additionalParams: [String : String]? } ``` diff --git a/docs/sdk/pnp/ios/install.mdx b/docs/sdk/pnp/ios/install.mdx index 4b3549d33..3d375b97b 100644 --- a/docs/sdk/pnp/ios/install.mdx +++ b/docs/sdk/pnp/ios/install.mdx @@ -17,14 +17,14 @@ description: "Installing Web3Auth PnP iOS SDK | Documentation - Web3Auth" https://github.com/Web3Auth/web3auth-swift-sdk ``` - From the `Dependency Rule` dropdown, select `Exact Version` and enter `7.3.0` as the version. + From the `Dependency Rule` dropdown, select `Exact Version` and enter `7.4.0` as the version. 1. When finished, Xcode will automatically begin resolving and downloading your dependencies in the background. ## Cocoapods ```sh -pod 'Web3Auth', '~> 7.2.0' +pod 'Web3Auth', '~> 7.4.0' ``` ## Configuration diff --git a/docs/sdk/pnp/ios/ios.mdx b/docs/sdk/pnp/ios/ios.mdx index 887325dbe..ab78367ba 100644 --- a/docs/sdk/pnp/ios/ios.mdx +++ b/docs/sdk/pnp/ios/ios.mdx @@ -10,7 +10,7 @@ iOS SDK is a client-side library you can use with your iOS app to authenticate u custodial way on successful authentication of the user. This authentication can be achieved by using any of the social logins Web3Auth provides or using a custom authentication flow of your choice. -#### This Documentation is based on the `7.3.0` SDK Version. +#### This Documentation is based on the `7.4.0` SDK Version. ### Requirements diff --git a/docs/sdk/pnp/ios/mfa.mdx b/docs/sdk/pnp/ios/mfa.mdx index 4e8f99646..dd5ce44fe 100644 --- a/docs/sdk/pnp/ios/mfa.mdx +++ b/docs/sdk/pnp/ios/mfa.mdx @@ -10,6 +10,12 @@ device and also to recover their account if they lose their original device. You can set the mfaLevel within the `loginParams` to customize when mfa screen should be shown to user. It currently accepts 4 values: +- **`default`** - Setting the mfaLevel to default will present the MFA screen to user on every third login. `mfaLevel = MFALevel.DEFAULT` +- **`optional`** - Setting mfaLevel to optional will present the MFA screen to user on every login but user will have the option to skip it. + `mfaLevel = MFALevel.OPTIONAL` +- **`mandatory`** - Setting mfaLevel to mandatory will make it mandatory for user to setup MFA after login. `mfaLevel = MFALevel.MANDATORY` +- **`none`** - Setting mfaLevel to none will skip the mfa setup screen totally. `mfaLevel = MFALevel.NONE` + ```swift Web3Auth().login(W3ALoginParams(loginProvider: provider, mfaLevel = MFALevel.MANDATORY)) ``` @@ -48,15 +54,9 @@ class ViewModel: ObservableObject { let result = try await Web3Auth().login( W3ALoginParams( loginProvider: provider, // can be .GOOGLE, .FACEBOOK, .APPLE etc - // highlight-start - mfaSettings: MfaSettings( - deviceShareFactor: .init(enable: true, priority: 1), - backUpShareFactor: .init(enable: true, priority: 2), - socialBackupFactor: .init(enable: true, priority: 3), - passwordFactor: .init(enable: true, priority: 4) - ) - // highlight-end - )) + // highlight-next-line + mfaLevel: MFALevel.MANDATORY + )) await MainActor.run(body: { user = result loggedIn = true @@ -70,3 +70,103 @@ class ViewModel: ObservableObject { } ``` + +## 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` + + + + + +`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 | + + + + + +```swift + + public struct MfaSetting: Codable { + public init(enable: Bool, priority: Int?, mandatory: Bool? = nil) { + self.enable = enable + self.priority = priority + self.mandatory = mandatory + } + + let enable: Bool + let priority: Int? + let mandatory: Bool? + } + + public struct MfaSettings: Codable { + public init(deviceShareFactor: MfaSetting?, backUpShareFactor: MfaSetting?, socialBackupFactor: MfaSetting?, passwordFactor: MfaSetting?) { + self.deviceShareFactor = deviceShareFactor + self.backUpShareFactor = backUpShareFactor + self.socialBackupFactor = socialBackupFactor + self.passwordFactor = passwordFactor + } + + let deviceShareFactor: MfaSetting? + let backUpShareFactor: MfaSetting? + let socialBackupFactor: MfaSetting? + let passwordFactor: MfaSetting? + } + + +``` + + + + + +```swift + let result = try await Web3Auth(.init( + clientId: clientId, + network: network, + loginConfig: [ + TypeOfLogin.google.rawValue: + .init( + verifier: "w3a-agg-example", + typeOfLogin: .google, + name: "Web3Auth-Aggregate-Verifier-Google-Example", + clientId: "774338308167-q463s7kpvja16l4l0kko3nb925ikds2p.apps.googleusercontent.com", + verifierSubIdentifier: "w3a-google" + ) + ], + whiteLabel: W3AWhiteLabelData( + appName: "Web3Auth Stub", + logoLight: "https://images.web3auth.io/web3auth-logo-w.svg", + logoDark: "https://images.web3auth.io/web3auth-logo-w.svg", + defaultLanguage: .en, // en, de, ja, ko, zh, es, fr, pt, nl + mode: .dark, + theme: ["primary": "#d53f8c"]), + mfaSettings: MfaSettings( + deviceShareFactor: MfaSetting(enable: true, priority: 1), + backUpShareFactor: MfaSetting(enable: true, priority: 2), + socialBackupFactor: MfaSetting(enable: true, priority: 3), + passwordFactor: MfaSetting(enable: true, priority: 4) + ) + )).login( + W3ALoginParams( + loginProvider: .GOOGLE, + dappShare: nil, + extraLoginOptions: ExtraLoginOptions(display: nil, prompt: nil, max_age: nil, ui_locales: nil, id_token_hint: nil, id_token: nil, login_hint: nil, acr_values: nil, scope: nil, audience: nil, connection: nil, domain: nil, client_id: nil, redirect_uri: nil, leeway: nil, verifierIdField: nil, isVerifierIdCaseSensitive: nil, additionalParams: nil), + mfaLevel: .DEFAULT, + curve: .SECP256K1 + )) +``` diff --git a/docs/sdk/pnp/ios/whitelabel.mdx b/docs/sdk/pnp/ios/whitelabel.mdx index 03651e930..2ec5965d2 100644 --- a/docs/sdk/pnp/ios/whitelabel.mdx +++ b/docs/sdk/pnp/ios/whitelabel.mdx @@ -25,16 +25,16 @@ For defining custom UI, branding, and translations for your brand app, you just -| Parameter | Type | Mandatory | Description | -| ----------------- | ------------------ | --------- | --------------------------------------- | -| `appName` | `String` | No | Name 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` | `Bool` | No | 3 Theme modes of the application | -| `theme` | `[String, String]` | No | Whitelabel theme | -| `appUrl` | `String` | No | Url of your application | -| `useLogoLoader` | `Bool` | 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 | +| `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` | `Language` | Default Language to use.
Choose from:
  • `en` - English
  • `de` - German
  • `ja` - Japanese
  • `ko` - Korean
  • `zh` - Mandarin
  • `es` - Spanish
  • `fr` - French
  • `pt` - Portuguese
  • `nl` - Dutch
| en - English | No | +| `mode` | `ThemeModes` | Choose between `auto`, `light` or `dark` modes. | `auto` | No | +| `theme` | `[String: String]` | Used to customize the theme of the login modal with the following options
`'primary'` - To customize the primary color of the modal's content | `#0364FF` | No | +| `appUrl` | `String` | App URL to be displayed in the User Flow Screens. | dApp's Website URL | No | +| `useLogoLoader` | `Bool` | Loads the logo when loading | false | No |
From 05c5a0c0c68c946c60378ff2b1cc00e79e102b14 Mon Sep 17 00:00:00 2001 From: hqjang-pepper Date: Tue, 14 Nov 2023 16:05:59 +0900 Subject: [PATCH 3/3] update pnp ios version to v7.4.1, and apply suggestion --- docs/pnp/migration-guides/ios-v6-to-v7.mdx | 57 ++++++++++++++-------- docs/sdk/pnp/ios/install.mdx | 2 +- docs/sdk/pnp/ios/ios.mdx | 2 +- 3 files changed, 40 insertions(+), 21 deletions(-) diff --git a/docs/pnp/migration-guides/ios-v6-to-v7.mdx b/docs/pnp/migration-guides/ios-v6-to-v7.mdx index 80a6e9904..5ea4ef470 100644 --- a/docs/pnp/migration-guides/ios-v6-to-v7.mdx +++ b/docs/pnp/migration-guides/ios-v6-to-v7.mdx @@ -27,19 +27,20 @@ let web3auth = Web3Auth(W3AInitParams( ### `Web3AuthState` now has more parameters -In v7, you should add `coreKitKey` and `coreKitEd25519PrivKey` field when you initialize `Web3authState`. +In v7, you can configure additional `coreKitKey` and `coreKitEd25519PrivKey` fields when you initialize `Web3authState`. ```swift -let user: Web3AuthState = .init(privKey: "12345", - ed25519PrivKey: "32334", - sessionId: "23234384y7735y47shdj", - userInfo: nil, - error: nil, +public struct Web3AuthState: Codable { + public let privKey: String? + public let ed25519PrivKey: String? + public let sessionId: String? + public let userInfo: Web3AuthUserInfo? + public let error: String? // highlight-start - coreKitKey: "45676", - coreKitEd25519PrivKey: "84567" + public let coreKitKey: String? + public let coreKitEd25519PrivKey: String? // highlight-end -) +} ``` ### `W3AInitParams` param configuration changed @@ -72,20 +73,38 @@ parameters have been added to `W3AInitParams`. -| Parameter | Type | Mandatory | Description | -| ----------------- | ------------------ | --------- | --------------------------------------- | -| `appName` | `String` | No | Name 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` | `Bool` | No | 3 Theme modes of the application | -| `theme` | `[String, String]` | No | Whitelabel theme | -| `appUrl` | `String` | No | Url of your application | -| `useLogoLoader` | `Bool` | 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 | +| `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` | `Language` | Default Language to use.
Choose from:
  • `en` - English
  • `de` - German
  • `ja` - Japanese
  • `ko` - Korean
  • `zh` - Mandarin
  • `es` - Spanish
  • `fr` - French
  • `pt` - Portuguese
  • `nl` - Dutch
| en - English | No | +| `mode` | `ThemeModes` | Choose between `auto`, `light` or `dark` modes. | `auto` | No | +| `theme` | `[String: String]` | Used to customize the theme of the login modal with the following options
`'primary'` - To customize the primary color of the modal's content | `#0364FF` | No | +| `appUrl` | `String` | App URL to be displayed in the User Flow Screens. | dApp's Website URL | No | +| `useLogoLoader` | `Bool` | Loads the logo when loading | false | No |
+ +```swift title="Usage" +web3Auth = await Web3Auth( + W3AInitParams( + clientId:"YOUR_CLIENT_ID", + network: .testnet, + // highlight-start + whiteLabel: W3AWhiteLabelData( + appName: "Web3Auth Stub", + logoLight: "https://images.web3auth.io/web3auth-logo-w.svg", + logoDark: "https://images.web3auth.io/web3auth-logo-w.svg", + defaultLanguage: .en, // en, de, ja, ko, zh, es, fr, pt, nl + mode: .dark + theme: ["primary": "#d53f8c"]) + )) + // highlight-end +``` + #### change of `W3AInitParams` object The `Web3Auth` constructor takes an object called `W3AInitParams` as input. The below are the aviliable fields of the `W3AInitParams` object. With v7, diff --git a/docs/sdk/pnp/ios/install.mdx b/docs/sdk/pnp/ios/install.mdx index 3d375b97b..1481a8670 100644 --- a/docs/sdk/pnp/ios/install.mdx +++ b/docs/sdk/pnp/ios/install.mdx @@ -24,7 +24,7 @@ description: "Installing Web3Auth PnP iOS SDK | Documentation - Web3Auth" ## Cocoapods ```sh -pod 'Web3Auth', '~> 7.4.0' +pod 'Web3Auth', '~> 7.4.1' ``` ## Configuration diff --git a/docs/sdk/pnp/ios/ios.mdx b/docs/sdk/pnp/ios/ios.mdx index ab78367ba..6d85e2eda 100644 --- a/docs/sdk/pnp/ios/ios.mdx +++ b/docs/sdk/pnp/ios/ios.mdx @@ -10,7 +10,7 @@ iOS SDK is a client-side library you can use with your iOS app to authenticate u custodial way on successful authentication of the user. This authentication can be achieved by using any of the social logins Web3Auth provides or using a custom authentication flow of your choice. -#### This Documentation is based on the `7.4.0` SDK Version. +#### This Documentation is based on the `7.4.1` SDK Version. ### Requirements