Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pnp swift v7 docs update #528

Merged
merged 7 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
153 changes: 153 additions & 0 deletions docs/pnp/migration-guides/ios-v6-to-v7.mdx
Original file line number Diff line number Diff line change
@@ -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: "<your 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

<Tabs
defaultValue="v7"
values={[
{ label: "V6", value: "v6" },
{ label: "V7", value: "v7" },
]}
>

<TabItem value="v6">

| 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 |

</TabItem>

<TabItem value="v7">

| 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 |

</TabItem>

</Tabs>

#### change of `W3AInitParams` object

The `Web3Auth` constructor takes an object called `W3AInitParams` as input. The below are the aviliable fields of the `W3AInitParams` object.

<Tabs
defaultValue="v7"
values={[
{ label: "V6", value: "v6" },
{ label: "V7", value: "v7" },
]}
>

<TabItem value="v6">

| 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`] |

</TabItem>

<TabItem value="v7">

| 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 |

</TabItem>

</Tabs>

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.
5 changes: 4 additions & 1 deletion docs/sdk/pnp/ios/initialize.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
4 changes: 2 additions & 2 deletions docs/sdk/pnp/ios/install.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/sdk/pnp/ios/ios.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
18 changes: 9 additions & 9 deletions docs/sdk/pnp/ios/mfa.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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))
```
Expand Down Expand Up @@ -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
Expand Down
32 changes: 18 additions & 14 deletions docs/sdk/pnp/ios/whitelabel.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,31 @@ For defining custom UI, branding, and translations for your brand app, you just

<TabItem value="table">

| 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 |

</TabItem>

<TabItem value="interface">

```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?
}
```

Expand All @@ -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
Expand Down
7 changes: 7 additions & 0 deletions sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
Expand Down