@@ -3,22 +3,7 @@ import { stringify } from "../../../utils/json.js";
3
3
import type { AsyncStorage } from "../../../utils/storage/AsyncStorage.js" ;
4
4
import { nativeLocalStorage } from "../../../utils/storage/nativeStorage.js" ;
5
5
import type { Account } from "../../interfaces/wallet.js" ;
6
- import { getUserStatus } from "../core/actions/get-enclave-user-status.js" ;
7
- import { authEndpoint } from "../core/authentication/authEndpoint.js" ;
8
- import { backendAuthenticate } from "../core/authentication/backend.js" ;
9
6
import { ClientScopedStorage } from "../core/authentication/client-scoped-storage.js" ;
10
- import { guestAuthenticate } from "../core/authentication/guest.js" ;
11
- import { customJwt } from "../core/authentication/jwt.js" ;
12
- import {
13
- getLinkedProfilesInternal ,
14
- linkAccount ,
15
- unlinkAccount ,
16
- } from "../core/authentication/linkAccount.js" ;
17
- import {
18
- loginWithPasskey ,
19
- registerPasskey ,
20
- } from "../core/authentication/passkeys.js" ;
21
- import { siweAuthenticate } from "../core/authentication/siwe.js" ;
22
7
import type {
23
8
AuthArgsType ,
24
9
AuthLoginReturnType ,
@@ -31,13 +16,9 @@ import type {
31
16
SingleStepAuthArgsType ,
32
17
} from "../core/authentication/types.js" ;
33
18
import type { InAppConnector } from "../core/interfaces/connector.js" ;
34
- import { EnclaveWallet } from "../core/wallet/enclave-wallet.js" ;
35
19
import type { Ecosystem } from "../core/wallet/types.js" ;
36
20
import type { IWebWallet } from "../core/wallet/web-wallet.js" ;
37
- import { sendOtp , verifyOtp } from "../web/lib/auth/otp.js" ;
38
- import { deleteActiveAccount , socialAuth } from "./auth/native-auth.js" ;
39
- import { logoutUser } from "./helpers/auth/logout.js" ;
40
- import { ShardedWallet } from "./helpers/wallet/sharded-wallet.js" ;
21
+
41
22
type NativeConnectorOptions = {
42
23
client : ThirdwebClient ;
43
24
ecosystem ?: Ecosystem ;
@@ -73,6 +54,9 @@ export class InAppNativeConnector implements InAppConnector {
73
54
"No auth token provided and no stored auth token found to initialize the wallet" ,
74
55
) ;
75
56
}
57
+ const { getUserStatus } = await import (
58
+ "../core/actions/get-enclave-user-status.js"
59
+ ) ;
76
60
const user = await getUserStatus ( {
77
61
authToken :
78
62
authResult ?. storedToken . cookieString || ( storedAuthToken as string ) ,
@@ -115,13 +99,19 @@ export class InAppNativeConnector implements InAppConnector {
115
99
}
116
100
117
101
if ( wallet && wallet . type === "enclave" ) {
102
+ const { EnclaveWallet } = await import (
103
+ "../core/wallet/enclave-wallet.js"
104
+ ) ;
118
105
this . wallet = new EnclaveWallet ( {
119
106
client : this . client ,
120
107
ecosystem : this . ecosystem ,
121
108
address : wallet . address ,
122
109
storage : this . storage ,
123
110
} ) ;
124
111
} else {
112
+ const { ShardedWallet } = await import (
113
+ "./helpers/wallet/sharded-wallet.js"
114
+ ) ;
125
115
this . wallet = new ShardedWallet ( {
126
116
client : this . client ,
127
117
storage : this . storage ,
@@ -150,7 +140,8 @@ export class InAppNativeConnector implements InAppConnector {
150
140
return this . wallet . getAccount ( ) ;
151
141
}
152
142
153
- preAuthenticate ( args : MultiStepAuthProviderType ) : Promise < void > {
143
+ async preAuthenticate ( args : MultiStepAuthProviderType ) : Promise < void > {
144
+ const { sendOtp } = await import ( "../web/lib/auth/otp.js" ) ;
154
145
return sendOtp ( {
155
146
...args ,
156
147
client : this . client ,
@@ -164,23 +155,33 @@ export class InAppNativeConnector implements InAppConnector {
164
155
switch ( strategy ) {
165
156
case "email" :
166
157
case "phone" : {
158
+ const { verifyOtp } = await import ( "../web/lib/auth/otp.js" ) ;
167
159
return verifyOtp ( params ) ;
168
160
}
169
161
case "guest" : {
162
+ const { guestAuthenticate } = await import (
163
+ "../core/authentication/guest.js"
164
+ ) ;
170
165
return guestAuthenticate ( {
171
166
client : this . client ,
172
167
ecosystem : params . ecosystem ,
173
168
storage : nativeLocalStorage ,
174
169
} ) ;
175
170
}
176
171
case "backend" : {
172
+ const { backendAuthenticate } = await import (
173
+ "../core/authentication/backend.js"
174
+ ) ;
177
175
return backendAuthenticate ( {
178
176
client : this . client ,
179
177
walletSecret : params . walletSecret ,
180
178
ecosystem : params . ecosystem ,
181
179
} ) ;
182
180
}
183
181
case "wallet" : {
182
+ const { siweAuthenticate } = await import (
183
+ "../core/authentication/siwe.js"
184
+ ) ;
184
185
return siweAuthenticate ( {
185
186
client : this . client ,
186
187
wallet : params . wallet ,
@@ -199,6 +200,7 @@ export class InAppNativeConnector implements InAppConnector {
199
200
case "line" :
200
201
case "x" :
201
202
case "apple" : {
203
+ const { socialAuth } = await import ( "./auth/native-auth.js" ) ;
202
204
const ExpoLinking = require ( "expo-linking" ) ;
203
205
const redirectUrl =
204
206
params . redirectUrl || ( ExpoLinking . createURL ( "" ) as string ) ;
@@ -210,18 +212,24 @@ export class InAppNativeConnector implements InAppConnector {
210
212
}
211
213
case "passkey" :
212
214
return this . passkeyAuth ( params ) ;
213
- case "jwt" :
215
+ case "jwt" : {
216
+ const { customJwt } = await import ( "../core/authentication/jwt.js" ) ;
214
217
return customJwt ( {
215
218
jwt : params . jwt ,
216
219
client : this . client ,
217
220
ecosystem : this . ecosystem ,
218
221
} ) ;
219
- case "auth_endpoint" :
222
+ }
223
+ case "auth_endpoint" : {
224
+ const { authEndpoint } = await import (
225
+ "../core/authentication/authEndpoint.js"
226
+ ) ;
220
227
return authEndpoint ( {
221
228
payload : params . payload ,
222
229
client : this . client ,
223
230
ecosystem : this . ecosystem ,
224
231
} ) ;
232
+ }
225
233
default :
226
234
throw new Error ( `Unsupported authentication type: ${ strategy } ` ) ;
227
235
}
@@ -287,6 +295,9 @@ export class InAppNativeConnector implements InAppConnector {
287
295
let authToken : AuthStoredTokenWithCookieReturnType ;
288
296
289
297
if ( type === "sign-up" ) {
298
+ const { registerPasskey } = await import (
299
+ "../core/authentication/passkeys.js"
300
+ ) ;
290
301
authToken = await registerPasskey ( {
291
302
client,
292
303
ecosystem,
@@ -299,6 +310,9 @@ export class InAppNativeConnector implements InAppConnector {
299
310
} ,
300
311
} ) ;
301
312
} else {
313
+ const { loginWithPasskey } = await import (
314
+ "../core/authentication/passkeys.js"
315
+ ) ;
302
316
authToken = await loginWithPasskey ( {
303
317
client,
304
318
ecosystem,
@@ -325,20 +339,25 @@ export class InAppNativeConnector implements InAppConnector {
325
339
326
340
// TODO (rn) expose in the interface
327
341
async deleteActiveAccount ( ) {
342
+ const { deleteActiveAccount } = await import ( "./auth/native-auth.js" ) ;
328
343
return deleteActiveAccount ( {
329
344
client : this . client ,
330
345
storage : this . storage ,
331
346
} ) ;
332
347
}
333
348
334
- logout ( ) : Promise < LogoutReturnType > {
349
+ async logout ( ) : Promise < LogoutReturnType > {
350
+ const { logoutUser } = await import ( "./helpers/auth/logout.js" ) ;
335
351
return logoutUser ( {
336
352
client : this . client ,
337
353
storage : this . storage ,
338
354
} ) ;
339
355
}
340
356
341
357
async linkProfile ( args : AuthArgsType ) {
358
+ const { linkAccount } = await import (
359
+ "../core/authentication/linkAccount.js"
360
+ ) ;
342
361
const { storedToken } = await this . authenticate ( args ) ;
343
362
return await linkAccount ( {
344
363
client : args . client ,
@@ -349,6 +368,9 @@ export class InAppNativeConnector implements InAppConnector {
349
368
}
350
369
351
370
async unlinkProfile ( profile : Profile ) {
371
+ const { unlinkAccount } = await import (
372
+ "../core/authentication/linkAccount.js"
373
+ ) ;
352
374
return await unlinkAccount ( {
353
375
client : this . client ,
354
376
ecosystem : this . ecosystem ,
@@ -358,6 +380,9 @@ export class InAppNativeConnector implements InAppConnector {
358
380
}
359
381
360
382
async getProfiles ( ) {
383
+ const { getLinkedProfilesInternal } = await import (
384
+ "../core/authentication/linkAccount.js"
385
+ ) ;
361
386
return getLinkedProfilesInternal ( {
362
387
client : this . client ,
363
388
ecosystem : this . ecosystem ,
0 commit comments