@@ -19,11 +19,16 @@ you'll see an Error message.
19
19
20
20
:::
21
21
22
+ ## Functionality Overview
23
+
22
24
The SingleFactorAuth instance natively provides the following methods:
23
25
24
- - [ connect] ( #login-user ) - Use to login user and retrive private key pair.
25
- - [ initialize] ( #session-management ) - This method helps to achieve session management. It
26
- authenticates user if the session is present, avoiding re-logging.
26
+ | Method | Description |
27
+ | ------------------------------------------ | ------------------------------------------------------------ |
28
+ | [ connect] ( #login-user ) | Use to login user and retrieve private key pair. |
29
+ | [ logout] ( #logout-user ) | Use to logout existing user. |
30
+ | [ connected] ( #check-users-logged-in-status ) | Use to check whether the user is logged in or not. |
31
+ | [ getSessionData] ( #get-session-data ) | This method helps to get the session data for valid session. |
27
32
28
33
## Login User
29
34
@@ -48,12 +53,13 @@ method. The method accepts `LoginParams`, and returns `SFAKey`.
48
53
>
49
54
50
55
<TabItem value = " table" >
51
- | Parameter | Description |
52
- | -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
53
- | ` verifier ` | The ` verifier ` parameter takes the name of the ustom verifier from the Web3Auth Dashboard. This is a required field that must be a ` String ` . If you're using an aggregate verifier, make sure to pass the sub-verifier name. |
54
- | ` verifierId ` | The ` verifierID ` takes the JWT verifier ID to be used for JWT/ID token verification. It can be an email, sub, or custom value available in the JWT token. |
55
- | ` idToken ` | The ` idToken ` accepts a JWT token obtained from the user's login provider. |
56
- | ` aggregateVerifier? ` | The ` aggregateVerifier ` parameter takes the name of the Aggregate verifier from the Web3Auth Dashboard. |
56
+
57
+ | Parameter | Description |
58
+ | ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
59
+ | ` verifier ` | The ` verifier ` parameter takes the name of the custom verifier from the Web3Auth Dashboard. This is a required field that must be a ` String ` . If you're using an aggregate verifier, make sure to pass the aggregate verifier name. |
60
+ | ` verifierId ` | The ` verifierID ` takes the JWT verifier ID to be used for JWT/ID token verification. It can be an email, sub, or custom value available in the JWT token. |
61
+ | ` idToken ` | The ` idToken ` accepts a JWT token obtained from the user's login provider. |
62
+ | ` subVerifierInfoArray? ` | Sub verifier info. Usually used during the aggregate verifier. It takes ` List<TorusSubVerifierInfo> ` as a value. |
57
63
58
64
</TabItem >
59
65
@@ -99,36 +105,96 @@ class LoginParams {
99
105
100
106
<TabItem value = " single-verifier" >
101
107
``` dart
102
- Future<SFAKey> connect() {
103
- return _singleFactorAuthFlutterPlugin.connect(LoginParams(
104
- verifier: 'YOUR_VERIFIER_NAME',
105
- verifierId: 'YOUR_VERIFIER_ID',
106
- idToken: 'YOUR_ID_TOKEN',
107
- ),
108
- );
109
- }
110
- ```
108
+ final loginParams = LoginParams(
109
+ verifier: 'YOUR_VERIFIER_NAME',
110
+ verifierId: 'YOUR_VERIFIER_ID',
111
+ idToken: 'YOUR_ID_TOKEN',
112
+ );
113
+
114
+ try { final sessionData = await singleFactorAuthFlutter.connect(loginParams); } catch (e) { //
115
+ Handle error }
116
+
117
+ ````
111
118
</TabItem>
112
119
<TabItem value="aggregate-verifier">
120
+
113
121
```dart
114
- Future<SFAKey> connect() {
115
- return _singleFactorAuthFlutterPlugin.connect(LoginParams(
116
- verifier: 'YOUR_VERIFIER_NAME',
117
- verifierId: 'YOUR_VERIFIER_ID',
118
- idToken: 'YOUR_ID_TOKEN',
119
- aggregateVerifier: 'YOUR_AGGREGATE_VERIFIER_NAME',
120
- ));
122
+
123
+ final subVerifierInfoArray = [
124
+ TorusSubVerifierInfo(
125
+ 'YOUR_SUB_VERIFIER_NAME',
126
+ 'YOUR_ID_TOKEN',
127
+ ),
128
+ ];
129
+
130
+ final loginParams = LoginParams(
131
+ verifier: 'YOUR_AGGREGATE_VERIFIER_NAME',
132
+ verifierId: 'YOUR_VERIFIER_ID',
133
+ idToken: 'YOUR_ID_TOKEN',
134
+ subVerifierInfoArray: subVerifierInfoArray,
135
+ );
136
+
137
+ try {
138
+ final sessionData = await singleFactorAuthFlutter.connect(loginParams);
139
+ } catch (e) {
140
+ // Handle error
121
141
}
122
- ```
142
+ ````
143
+
123
144
</TabItem>
124
145
</Tabs>
125
146
126
- ## Session Management
147
+ ## Logout User
127
148
128
- We have included Session Management in this SDK, so calling the initialize function to get the
129
- SFAKey value without re-logging in the user if a user has an active session will return the SFAKey,
130
- otherwise, it will throw an error.
149
+ To logout the current user, you can use the `logout` method. Please note, the method will not logout
150
+ the user from the authentication provider, it'll only logout and invalidate the Web3Auth session.
151
+
152
+ ### Usage
153
+
154
+ ```dart
155
+ try {
156
+ await singleFactorAuthFlutter.logout();
157
+ // Logged out successfully
158
+ } catch (e) {
159
+ // Handle error
160
+ }
161
+ ```
162
+
163
+ ## Check User's Logged In Status
164
+
165
+ You can use the ` connected ` method to check whether the user is logged in Web3Auth or not. Please
166
+ note, you should call this method after the ` initialize ` method if you want to check the user's
167
+ connection status for an existing session.
168
+
169
+ ### Usage
170
+
171
+ ``` dart
172
+ final isConnected = await singleFactorAuthFlutter.connected();
173
+ ```
174
+
175
+ ## Get Session Data
176
+
177
+ We have included Session Management in this SDK, so calling the ` getSessionData ` will retrive the
178
+ user's ` SessionData ` without re-logging in the user if a user has an active session. Otherwise, it
179
+ will return ` null ` .
180
+
181
+ :::tip
182
+
183
+ Please note, you should use this method after the ` initialize ` method.
184
+
185
+ :::
131
186
132
187
### Usage
133
188
134
189
<SessionManagement />
190
+
191
+ ### Response
192
+
193
+ The ` SessionData ` has the following properties to retrive the relevant session information.
194
+
195
+ | Name | Description |
196
+ | --------------- | ------------------------------------------------------------------------- |
197
+ | ` privateKey ` | Retrieves the user's private key. |
198
+ | ` publicAddress ` | Retrieves the user's public address. |
199
+ | ` userInfo? ` | Retrieves the user's information like email, name, verifier id, and more. |
200
+ | ` signatures? ` | Retrieves the node's signatures that are returned for request. |
0 commit comments