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
4 changes: 2 additions & 2 deletions docs/sdk/pnp/ios/usage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ do {
// focus-start
try await web3Auth!.launchWalletServices(
chainConfig: ChainConfig(
chainId: "11155111",
chainId: "0xaa36a7",
rpcTarget: "https://eth-sepolia.public.blastapi.io"
)
)
Expand Down Expand Up @@ -523,7 +523,7 @@ do {
// focus-start
let response = try await web3Auth?.request(
chainConfig: ChainConfig(
chainId: "11155111",
chainId: "0xaa36a7",
rpcTarget: "https://eth-sepolia.public.blastapi.io"
),
method: "personal_sign",
Expand Down
16 changes: 9 additions & 7 deletions docs/sdk/sfa/sfa-ios/initialize.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ according to the preference of your project.
The `SingleFactoreAuth` constructor takes an object called `Web3AuthOptions` as input. The
constructor parameters are listed below

| Parameter | Description |
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `clientId` | Your Web3Auth Client Id from [Web3Auth Dashboard](https://dashboard.web3auth.io/). |
| `web3AuthNetwork` | The Web3auth network to be used by the SDK. Supported values are `.SAPPHIRE_MAINNET`, `.SAPPHIRE_DEVNET`, `.MAINNET`, `.TESTNET`, `.CYAN`, and `.AQUA` |
| `sessionTime` | Specifies the session duration in seconds. By default, the value is set to 86400 seconds (1 day), with a maximum session duration of up to 30 days. |
| `serverTimeOffset` | Specifies the server time offset in seconds. This parameter is used to adjust the server time to the local time. The default value is 0 seconds. |
| `storageServerUrl?` | Specifies the storage server URL. The default value is `https://session.web3auth.io`. |
| Parameter | Description |
| ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `clientId` | Your Web3Auth Client Id from [Web3Auth Dashboard](https://dashboard.web3auth.io/). |
| `web3AuthNetwork` | The Web3auth network to be used by the SDK. Supported values are `.SAPPHIRE_MAINNET`, `.SAPPHIRE_DEVNET`, `.MAINNET`, `.TESTNET`, `.CYAN`, and `.AQUA` |
| `sessionTime` | Specifies the session duration in seconds. By default, the value is set to 86400 seconds (1 day), with a maximum session duration of up to 30 days. |
| `serverTimeOffset` | Specifies the server time offset in seconds. This parameter is used to adjust the server time to the local time. The default value is 0 seconds. |
| `storageServerUrl?` | Specifies the storage server URL. The default value is `https://session.web3auth.io`. |
| `whiteLabel?` | You can pass the white labeling options for Web3Auth. It helps you define your brand app's custom UI, and branding for the Wallet Services and request signature feature. The recommended way to configure the `whiteLabel` is through the Web3Auth Dashboard. [Learn how to configure the `whiteLabel` via Web3Auth Dashboard](/docs/features/whitelabel#new-whitelabeling-via-the-dashboard). |
| `redirectUrl?` | URL that Web3Auth will redirect API responses upon successful `request` method call. Please note, that it's mandatory to configure the `redirectUrl` if you are using the `request` method. Redirect Url shoudl be your bundle identifier. |

## Create instance

Expand Down
180 changes: 167 additions & 13 deletions docs/sdk/sfa/sfa-ios/usage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ you'll see an Error message.

The SingleFactorAuth instance natively provides the following methods:

| Method | Description |
| ------------------------------------------ | ------------------------------------------------------------ |
| [connect](#login-user) | Use to login user and retrieve private key pair. |
| [logout](#logout-user) | Use to logout existing user. |
| [connected](#check-users-logged-in-status) | Use to check whether the user is logged in or not. |
| [getSessionData](#get-session-data) | This method helps to get the session data for valid session. |
| Method | Description |
| ------------------------------------------ | ------------------------------------------------------------------- |
| [connect](#login-user) | Use to login user and retrieve private key pair. |
| [logout](#logout-user) | Use to logout existing user. |
| [connected](#check-users-logged-in-status) | Use to check whether the user is logged in or not. |
| [getSessionData](#get-session-data) | This method helps to get the session data for valid session. |
| [showWalletUI](#show-wallet-ui) | Use to open templated the wallet UI in WebView. |
| [request](#request-signature) | Use to open templated transaction screens for signing transactions. |

## Login User

Expand Down Expand Up @@ -162,11 +164,163 @@ if(sessionData != nil) {

### Response

The `SessionData` has the following four functions to retrive the relevant session information.
The `SessionData` has the following four properties to retrive the relevant session information.

| Function Name | Description |
| ------------------ | ------------------------------------------------------------------------- |
| `getPrivateKey` | Retrieves the user's private key. |
| `getPublicAddress` | Retrieves the user's public address. |
| `getUserInfo` | Retrieves the user's information like email, name, verifier id, and more. |
| `getSignatures` | Retrieves the node's signatures that are returned for request. |
| Name | Description |
| --------------- | ------------------------------------------------------------------------- |
| `privateKey` | Retrieves the user's private key. |
| `publicAddress` | Retrieves the user's public address. |
| `userInfo` | Retrieves the user's information like email, name, verifier id, and more. |
| `signatures` | Retrieves the node's signatures that are returned for request. |

## Show Wallet UI

The `showWalletUI` method launches a WebView which allows you to use the templated wallet UI
services. The method takes `ChainConfig` as the required input. Wallet Services is currently only
available for EVM chains.

:::note

Access to Wallet Services is gated. You can use this feature in `sapphire_devnet` for free. The
minimum [pricing plan](https://web3auth.io/pricing.html) to use this feature in a production
environment is the **Scale Plan**.

:::

![Wallet Services](/images/mobile-wallet-services.png)

### Parameters

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

<TabItem value="table">

| Parameter | Description |
| ------------------- | --------------------------------------------------------------------------------------------------------------------------- |
| `chainNamespace` | Custom configuration for your preferred blockchain. As of now only EVM supported. Default value is `ChainNamespace.eip155`. |
| `decimals?` | Number of decimals for the currency ticker. Default value is 18, and accepts `Int` as value. |
| `blockExplorerUrl?` | Blockchain's explorer URL. (eg: `https://etherscan.io`) |
| `chainId` | The chain id of the selected blockchain in hex string format. |
| `displayName?` | Display Name for the chain. |
| `logo?` | Logo for the selected `chainNamespace` & `chainId`. |
| `rpcTarget` | RPC Target URL for the selected `chainNamespace` & `chainId`. |
| `ticker?` | Default currency ticker of the network (e.g: `ETH`) |
| `tickerName?` | Name for currency ticker (e.g: `Ethereum`) |

</TabItem>

<TabItem value="class">

```swift
public enum ChainNamespace: String, Codable {
case eip155
case solana
}

public struct ChainConfig: Codable {
public init(chainNamespace: ChainNamespace = ChainNamespace.eip155, decimals: Int? = 18, blockExplorerUrl: String? = nil, chainId: String, displayName: String? = nil, logo: String? = nil, rpcTarget: String, ticker: String? = nil, tickerName: String? = nil) {
self.chainNamespace = chainNamespace
self.decimals = decimals
self.blockExplorerUrl = blockExplorerUrl
self.chainId = chainId
self.displayName = displayName
self.logo = logo
self.rpcTarget = rpcTarget
self.ticker = ticker
self.tickerName = tickerName
}
}
```

</TabItem>
</Tabs>

### Usage

```swift
do {
try await web3Auth.showWalletUI(
chainConfig: ChainConfig(
chainId: "0xaa36a7",
rpcTarget: "https://eth-sepolia.public.blastapi.io"
)
)
} catch {
// Handle error
}
```

## Request signature

The `request` method facilitates the use of templated transaction screens for signing transactions.
The method will return [SignResponse](#signresponse). It can be used to sign transactions for any
EVM chain and screens can be whitelabeled to your branding.

Please check the list of
[JSON RPC methods](https://docs.metamask.io/wallet/reference/json-rpc-api/), noting that the request
method currently supports only the signing methods.

:::note

Please note, to use the `request` method, you need to configure the `redirectUrl` in the
[`Web3AuthOptions`](/docs/sdk/sfa/sfa-ios/initialize#parameters) while initializing the SDK.

:::

![Request Method](/images/mobile-request-method.png)

### Parameters

| Parameter | Description |
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `chainConfig` | Defines the chain to be used for signature. |
| `method` | JSON RPC method name in `String`. Currently, the request method only supports the singing methods. |
| `requestParams` | Parameters for the corresponding method. The parameters should be in the list and correct sequence. Take a look at [RPC methods](https://docs.metamask.io/wallet/reference/json-rpc-api/) to know more. |

### Usage

```swift
do {
var params = [Any]()
// Message to be signed
params.append("Hello, Web3Auth from iOS!")
// User's EOA address
params.append(address)

// focus-start
let response = try await web3Auth.request(
chainConfig: ChainConfig(
chainId: "0xaa36a7",
rpcTarget: "https://eth-sepolia.public.blastapi.io"
),
method: "personal_sign",
requestParams: params
)
// focus-end

if response!.success {
print(response!.result!)
} else {
// Handle Error
print(response!.error!)
}

} catch {
print(error.localizedDescription)
// Handle error
}
```

### SignResponse

| Name | Description |
| --------- | ------------------------------------------------------------- |
| `success` | Determines whether the request was successful or not. |
| `result?` | Holds the signature for the request when `success` is `true`. |
| `error?` | Holds the error for the request when `success` is `false`. |
2 changes: 1 addition & 1 deletion src/common/sdk/sfa/ios/_sfa-ios-cocoapods.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ To install the Web3Auth SingleFactorAuth SDK using Cocoapods, follow the below s
1. Open the Podfile, and add the SingleFactorAuth pod:

```sh
pod 'SingleFactorAuth', '~> 9.0.4'
pod 'SingleFactorAuth', '~> 9.1.0'
```

2. Once added, use `pod install` command to download the SingleFactorAuth dependency.
2 changes: 1 addition & 1 deletion src/common/sdk/sfa/ios/_sfa-ios-spm.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
https://github.com/Web3Auth/single-factor-auth-swift
```

From the `Dependency Rule` dropdown, select `Exact Version` and enter `9.0.4` as the version.
From the `Dependency Rule` dropdown, select `Exact Version` and enter `9.1.0` as the version.

1. When finished, Xcode will automatically begin resolving and downloading your dependencies in the
background.
2 changes: 1 addition & 1 deletion src/common/versions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const pnpUnrealVersion = `4.1.x`;

export const sfaWebVersion = `9.2.x`;
export const sfaAndroidVersion = `4.0.0`;
export const sfaIOSVersion = `9.0.4`;
export const sfaIOSVersion = `9.1.0`;
export const sfaRNVersion = `2.0.x`;
export const sfaFlutterVersion = `6.0.0`;
export const sfaNodeJSVersion = `7.4.x`;
Expand Down