@@ -4,12 +4,10 @@ import {
4
4
Export ,
5
5
Import ,
6
6
useTurnkey ,
7
- getSuborgs ,
8
- getVerifiedSuborgs ,
9
7
OtpVerification ,
10
8
OtpType ,
11
- initOtpAuth ,
12
9
} from "@turnkey/sdk-react" ;
10
+ import { server } from "@turnkey/sdk-server" ;
13
11
import { useEffect , useState } from "react" ;
14
12
import "./dashboard.css" ;
15
13
import {
@@ -84,31 +82,31 @@ export default function Dashboard() {
84
82
toast . success ( "Wallet successfully imported" ) ;
85
83
} ;
86
84
const handleResendEmail = async ( ) => {
87
- const initAuthResponse = await initOtpAuth ( {
85
+ const sendOtpResponse = await server . sendOtp ( {
88
86
suborgID : suborgId ,
89
87
otpType : OtpType . Email ,
90
88
contact : emailInput ,
91
89
userIdentifier : authIframeClient ?. iframePublicKey ! ,
92
90
} ) ;
93
- if ( ! initAuthResponse || ! initAuthResponse . otpId ! ) {
91
+ if ( ! sendOtpResponse || ! sendOtpResponse . otpId ! ) {
94
92
toast . error ( "Failed to send OTP" ) ;
95
93
return ;
96
94
}
97
- setOtpId ( initAuthResponse ?. otpId ! ) ;
95
+ setOtpId ( sendOtpResponse ?. otpId ! ) ;
98
96
} ;
99
97
const handleResendSms = async ( ) => {
100
- const initAuthResponse = await initOtpAuth ( {
98
+ const sendOtpResponse = await server . sendOtp ( {
101
99
suborgID : suborgId ,
102
100
otpType : OtpType . Sms ,
103
101
contact : phoneInput ,
104
102
customSmsMessage : "Your Turnkey Demo OTP is {{.OtpCode}}" ,
105
103
userIdentifier : authIframeClient ?. iframePublicKey ! ,
106
104
} ) ;
107
- if ( ! initAuthResponse || ! initAuthResponse . otpId ! ) {
105
+ if ( ! sendOtpResponse || ! sendOtpResponse . otpId ! ) {
108
106
toast . error ( "Failed to send OTP" ) ;
109
107
return ;
110
108
}
111
- setOtpId ( initAuthResponse ?. otpId ! ) ;
109
+ setOtpId ( sendOtpResponse ?. otpId ! ) ;
112
110
} ;
113
111
114
112
const handleOtpSuccess = async ( credentialBundle : any ) => {
@@ -125,7 +123,7 @@ export default function Dashboard() {
125
123
toast . error ( "Please enter a valid email address" ) ;
126
124
return ;
127
125
}
128
- const suborgs = await getVerifiedSuborgs ( {
126
+ const suborgs = await server . getVerifiedSuborgs ( {
129
127
filterType : "EMAIL" ,
130
128
filterValue : emailInput ,
131
129
} ) ;
@@ -139,17 +137,17 @@ export default function Dashboard() {
139
137
userEmail : emailInput ,
140
138
userTagIds : [ ] ,
141
139
} ) ;
142
- const initAuthResponse = await initOtpAuth ( {
140
+ const sendOtpResponse = await server . sendOtp ( {
143
141
suborgID : suborgId ,
144
142
otpType : OtpType . Email ,
145
143
contact : emailInput ,
146
144
userIdentifier : authIframeClient ?. iframePublicKey ! ,
147
145
} ) ;
148
- if ( ! initAuthResponse || ! initAuthResponse . otpId ! ) {
146
+ if ( ! sendOtpResponse || ! sendOtpResponse . otpId ! ) {
149
147
toast . error ( "Failed to send OTP" ) ;
150
148
return ;
151
149
}
152
- setOtpId ( initAuthResponse ?. otpId ! ) ;
150
+ setOtpId ( sendOtpResponse ?. otpId ! ) ;
153
151
setIsEmailModalOpen ( false ) ;
154
152
setIsOtpModalOpen ( true ) ;
155
153
} ;
@@ -159,7 +157,7 @@ export default function Dashboard() {
159
157
toast . error ( "Please enter a valid phone number." ) ;
160
158
return ;
161
159
}
162
- const suborgs = await getVerifiedSuborgs ( {
160
+ const suborgs = await server . getVerifiedSuborgs ( {
163
161
filterType : "PHONE_NUMBER" ,
164
162
filterValue : phoneInput ,
165
163
} ) ;
@@ -173,18 +171,18 @@ export default function Dashboard() {
173
171
userPhoneNumber : phoneInput ,
174
172
userTagIds : [ ] ,
175
173
} ) ;
176
- const initAuthResponse = await initOtpAuth ( {
174
+ const sendOtpResponse = await server . sendOtp ( {
177
175
suborgID : suborgId ,
178
176
otpType : OtpType . Sms ,
179
177
contact : phoneInput ,
180
178
customSmsMessage : "Your Turnkey Demo OTP is {{.OtpCode}}" ,
181
179
userIdentifier : authIframeClient ?. iframePublicKey ! ,
182
180
} ) ;
183
- if ( ! initAuthResponse || ! initAuthResponse . otpId ! ) {
181
+ if ( ! sendOtpResponse || ! sendOtpResponse . otpId ! ) {
184
182
toast . error ( "Failed to send OTP" ) ;
185
183
return ;
186
184
}
187
- setOtpId ( initAuthResponse ?. otpId ! ) ;
185
+ setOtpId ( sendOtpResponse ?. otpId ! ) ;
188
186
setIsEmailModalOpen ( false ) ;
189
187
setIsOtpModalOpen ( true ) ;
190
188
} ;
@@ -223,7 +221,7 @@ export default function Dashboard() {
223
221
console . error ( `Unknown OAuth type: ${ oauthType } ` ) ;
224
222
}
225
223
if ( oidcToken ) {
226
- const suborgs = await getSuborgs ( {
224
+ const suborgs = await server . getSuborgs ( {
227
225
filterType : "OIDC_TOKEN" ,
228
226
filterValue : oidcToken . idToken ,
229
227
} ) ;
@@ -323,7 +321,7 @@ export default function Dashboard() {
323
321
} ) ;
324
322
setWallets ( walletsResponse . wallets ) ;
325
323
if ( userResponse . user . userEmail ) {
326
- const suborgs = await getVerifiedSuborgs ( {
324
+ const suborgs = await server . getVerifiedSuborgs ( {
327
325
filterType : "EMAIL" ,
328
326
filterValue : userResponse . user . userEmail ,
329
327
} ) ;
@@ -337,7 +335,7 @@ export default function Dashboard() {
337
335
}
338
336
}
339
337
if ( userResponse . user . userPhoneNumber ) {
340
- const suborgs = await getVerifiedSuborgs ( {
338
+ const suborgs = await server . getVerifiedSuborgs ( {
341
339
filterType : "PHONE_NUMBER" ,
342
340
filterValue : userResponse . user . userPhoneNumber ,
343
341
} ) ;
0 commit comments