Skip to content

Commit 253140e

Browse files
fix review comments
1 parent a28c402 commit 253140e

File tree

3 files changed

+70
-24
lines changed

3 files changed

+70
-24
lines changed

docs/migration-guides/sfa-ios-v8-to-v9.mdx

+41-7
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ guide outlines significant changes and enhancements.
1111

1212
### Web3AuthNetwork Changes
1313

14-
In v9, we have removed the nest enum and refactored the Web3AuthNetwork. Please checkout the table
14+
In v9, we have removed the nested enum and refactored the Web3AuthNetwork. Please checkout the table
1515
below for the changes.
1616

1717
| Old Value | New Value |
@@ -29,8 +29,10 @@ In v9, we try to improve the developer experience by renaming the `SFAParams` to
2929
It has been renamed to align with naming conventions across Web3Auth SDKs. Along with this, we have
3030
renamed couple of constructor parameters.
3131

32-
- `web3AuthClientId` is reanmed to `clientId`.
33-
- `network` is reanmed to `web3AuthNetwork`.
32+
- `web3AuthClientId` is renamed to `clientId`.
33+
- `network` is renamed to `web3AuthNetwork`.
34+
35+
[Checkout Web3AuthOptions for available parameters](/docs/sdk/core-kit/sfa-ios/initialize#parameters).
3436

3537
```swift
3638
// remove-start
@@ -67,6 +69,26 @@ let sfaKey: SFAKey = try await singleFactoreAuth.connect(loginParams: loginParam
6769
let sessionData: SessionData = try await singleFactoreAuth.connect(loginParams: loginParams)
6870
```
6971

72+
### getTorusKey method is now private
73+
74+
The `getTorusKey` method is now private and can no longer be accessible. You can use the `connect`
75+
method to login user.
76+
77+
```swift
78+
let loginParams = LoginParams(
79+
verifier: "YOUR_VERIFIER_NAME",
80+
verifierId: "VERIFIER_ID",
81+
idToken: "ID_TOKEN"
82+
)
83+
84+
// focus-start
85+
// remove-next-line
86+
let torusKey: TorusSFAKey = try await singleFactoreAuth.getTorusKey(loginParams: loginParams)
87+
// add-next-line
88+
let sessionData: SessionData = try await singleFactoreAuth.connect(loginParams: loginParams)
89+
// focus-end
90+
```
91+
7092
### initialize method changes
7193

7294
Starting v9, the `initialize` method will not return any value. To check whether the user already
@@ -95,7 +117,8 @@ developer experience.
95117
### logout Method
96118

97119
The `logout` method is added to the SDK to log out the user and clear the session data. Please note,
98-
that this method only clears the Web3Auth session from local storage.
120+
that this method only logout the user and invalides the Web3Auth session, and not the OAuth provider
121+
session.
99122

100123
```swift
101124
try await singleFactoreAuth.logout()
@@ -104,7 +127,8 @@ try await singleFactoreAuth.logout()
104127
### getSessionData Method
105128

106129
The `getSessionData` method is added to the SDK to get the session data. You can use this method to
107-
check whether the user already has an existing session.
130+
retrive the session data for an existing session. The method will return `nil` if the user does not
131+
have an existing session.
108132

109133
#### Usage
110134

@@ -116,7 +140,7 @@ if sessionData == nil {
116140
}
117141
```
118142

119-
#### SessionData Response
143+
#### SessionData
120144

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

@@ -125,4 +149,14 @@ The `SessionData` has the following four functions to retrive the relevant sessi
125149
| `getPrivateKey` | Retrieves the user's private key. |
126150
| `getPublicAddress` | Retrieves the user's public address. |
127151
| `getUserInfo` | Retrieves the user's information like email, name, verifier id, and more. |
128-
| `getSignatures` | Retrieves the signatures. |
152+
| `getSignatures` | Retrieves the node's signatures that are returned for request. |
153+
154+
### connected Method
155+
156+
The `connected` method can be used to check whether the user is logged in Web3Auth or not. Please
157+
note, you should call this method after the `initialize` method if you want to check the user's
158+
connection status for an existing session.
159+
160+
```swift
161+
let isConnected = singleFactoreAuth.connected()
162+
```

docs/sdk/core-kit/sfa-ios/initialize.mdx

+7-5
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@ according to the preference of your project.
1515
The `SingleFactoreAuth` constructor takes an object called `Web3AuthOptions` as input. The
1616
constructor parameters are listed below
1717

18-
| Parameter | Description |
19-
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
20-
| `clientId` | Your Web3Auth Client Id from [Web3Auth Dashboard](https://dashboard.web3auth.io/). |
21-
| `web3AuthNetwork` | The Web3auth network to be used by the SDK. Supported values are `.SAPPHIRE_MAINNET`, `.SAPPHIRE_DEVNET`, `.MAINNET`, `.TESTNET`, `.CYAN`, and `.AQUA` |
22-
| `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 7 days. |
18+
| Parameter | Description |
19+
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
20+
| `clientId` | Your Web3Auth Client Id from [Web3Auth Dashboard](https://dashboard.web3auth.io/). |
21+
| `web3AuthNetwork` | The Web3auth network to be used by the SDK. Supported values are `.SAPPHIRE_MAINNET`, `.SAPPHIRE_DEVNET`, `.MAINNET`, `.TESTNET`, `.CYAN`, and `.AQUA` |
22+
| `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 7 days. |
23+
| `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. |
24+
| `storageServerUrl?` | Specifies the storage server URL. The default value is `https://session.web3auth.io`. |
2325

2426
## Initialize SingleFactorAuth
2527

docs/sdk/core-kit/sfa-ios/usage.mdx

+22-12
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ The SingleFactorAuth instance natively provides the following methods:
2323

2424
- [connect](#login-user) - Use to login user and retrive private key pair.
2525
- [logout](#logout-user) - Use to logout existing user.
26-
- [getSessionData](#get-session-data) - This method helps to get the session data if exists. You can
27-
use it to check if the user is logged in or not.
26+
- [connected](#check-users-logged-in-status) - Use to check whether the user is logged in or not.
27+
- [getSessionData](#get-session-data) - This method helps to get the session data for valid session.
2828

2929
## Login User
3030

@@ -50,6 +50,7 @@ The method accepts `LoginParams`, and returns `SessionData`.
5050
| `verifierId` | The verifierId used for the verification. It takes `String` as a value. |
5151
| `idToken` | The idToken of the user obtained from login provider. It takes `String` as a value. |
5252
| `subVerifierInfoArray?` | Sub verifier info. Usually used during aggregate verifier. It takes `[TorusSubVerifierInfo]` as a value. |
53+
| `serverTimeOffset?` | Specifies the server time offset in seconds. |
5354

5455
</TabItem>
5556

@@ -61,19 +62,16 @@ public class LoginParams {
6162
public let verifierId: String
6263
public let idToken: String
6364
public let subVerifierInfoArray: [TorusSubVerifierInfo]?
65+
public let serverTimeOffset: Int?
66+
public let fallbackUserInfo: UserInfo?
6467

65-
public init(verifier: String, verifierId: String, idToken: String) {
66-
self.verifier = verifier
67-
self.verifierId = verifierId
68-
self.idToken = idToken
69-
subVerifierInfoArray = nil
70-
}
71-
72-
public init(verifier: String, verifierId: String, idToken: String, subVerifierInfoArray: [TorusSubVerifierInfo]) {
68+
public init(verifier: String, verifierId: String, idToken: String, subVerifierInfoArray: [TorusSubVerifierInfo]? = nil, serverTimeOffset: Int? = nil, fallbackUserInfo: UserInfo? = nil) {
7369
self.verifier = verifier
7470
self.verifierId = verifierId
7571
self.idToken = idToken
7672
self.subVerifierInfoArray = subVerifierInfoArray
73+
self.serverTimeOffset = serverTimeOffset
74+
self.fallbackUserInfo = fallbackUserInfo
7775
}
7876
}
7977

@@ -105,7 +103,7 @@ do {
105103
## Logout User
106104

107105
To logout the current user, you can use the `logout` method. Please note, the method will not logout
108-
the user from the authentication provider, it'll only delete the session from the local storage.
106+
the user from the authentication provider, it'll only logout and invalidate the Web3Auth session.
109107

110108
### Usage
111109

@@ -117,6 +115,18 @@ do {
117115
}
118116
```
119117

118+
## Check User's Logged In Status
119+
120+
You can use the `connected` method to check whether the user is logged in Web3Auth or not. Please
121+
note, you should call this method after the `initialize` method if you want to check the user's
122+
connection status for an existing session.
123+
124+
### Usage
125+
126+
```swift
127+
let isConnected = singleFactorAuth.connected()
128+
```
129+
120130
## Get Session Data
121131

122132
We have included Session Management in this SDK, so calling the `getSessionData` will retrive the
@@ -144,4 +154,4 @@ The `SessionData` has the following four functions to retrive the relevant sessi
144154
| `getPrivateKey` | Retrieves the user's private key. |
145155
| `getPublicAddress` | Retrieves the user's public address. |
146156
| `getUserInfo` | Retrieves the user's information like email, name, verifier id, and more. |
147-
| `getSignatures` | Retrieves the signatures. |
157+
| `getSignatures` | Retrieves the node's signatures that are returned for request. |

0 commit comments

Comments
 (0)