@@ -3,22 +3,7 @@ import { stringify } from "../../../utils/json.js";
33import type { AsyncStorage } from "../../../utils/storage/AsyncStorage.js" ;
44import { nativeLocalStorage } from "../../../utils/storage/nativeStorage.js" ;
55import 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" ;
96import { 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" ;
227import type {
238 AuthArgsType ,
249 AuthLoginReturnType ,
@@ -31,13 +16,9 @@ import type {
3116 SingleStepAuthArgsType ,
3217} from "../core/authentication/types.js" ;
3318import type { InAppConnector } from "../core/interfaces/connector.js" ;
34- import { EnclaveWallet } from "../core/wallet/enclave-wallet.js" ;
3519import type { Ecosystem } from "../core/wallet/types.js" ;
3620import 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+
4122type NativeConnectorOptions = {
4223 client : ThirdwebClient ;
4324 ecosystem ?: Ecosystem ;
@@ -73,6 +54,9 @@ export class InAppNativeConnector implements InAppConnector {
7354 "No auth token provided and no stored auth token found to initialize the wallet" ,
7455 ) ;
7556 }
57+ const { getUserStatus } = await import (
58+ "../core/actions/get-enclave-user-status.js"
59+ ) ;
7660 const user = await getUserStatus ( {
7761 authToken :
7862 authResult ?. storedToken . cookieString || ( storedAuthToken as string ) ,
@@ -115,13 +99,19 @@ export class InAppNativeConnector implements InAppConnector {
11599 }
116100
117101 if ( wallet && wallet . type === "enclave" ) {
102+ const { EnclaveWallet } = await import (
103+ "../core/wallet/enclave-wallet.js"
104+ ) ;
118105 this . wallet = new EnclaveWallet ( {
119106 client : this . client ,
120107 ecosystem : this . ecosystem ,
121108 address : wallet . address ,
122109 storage : this . storage ,
123110 } ) ;
124111 } else {
112+ const { ShardedWallet } = await import (
113+ "./helpers/wallet/sharded-wallet.js"
114+ ) ;
125115 this . wallet = new ShardedWallet ( {
126116 client : this . client ,
127117 storage : this . storage ,
@@ -150,7 +140,8 @@ export class InAppNativeConnector implements InAppConnector {
150140 return this . wallet . getAccount ( ) ;
151141 }
152142
153- preAuthenticate ( args : MultiStepAuthProviderType ) : Promise < void > {
143+ async preAuthenticate ( args : MultiStepAuthProviderType ) : Promise < void > {
144+ const { sendOtp } = await import ( "../web/lib/auth/otp.js" ) ;
154145 return sendOtp ( {
155146 ...args ,
156147 client : this . client ,
@@ -164,23 +155,33 @@ export class InAppNativeConnector implements InAppConnector {
164155 switch ( strategy ) {
165156 case "email" :
166157 case "phone" : {
158+ const { verifyOtp } = await import ( "../web/lib/auth/otp.js" ) ;
167159 return verifyOtp ( params ) ;
168160 }
169161 case "guest" : {
162+ const { guestAuthenticate } = await import (
163+ "../core/authentication/guest.js"
164+ ) ;
170165 return guestAuthenticate ( {
171166 client : this . client ,
172167 ecosystem : params . ecosystem ,
173168 storage : nativeLocalStorage ,
174169 } ) ;
175170 }
176171 case "backend" : {
172+ const { backendAuthenticate } = await import (
173+ "../core/authentication/backend.js"
174+ ) ;
177175 return backendAuthenticate ( {
178176 client : this . client ,
179177 walletSecret : params . walletSecret ,
180178 ecosystem : params . ecosystem ,
181179 } ) ;
182180 }
183181 case "wallet" : {
182+ const { siweAuthenticate } = await import (
183+ "../core/authentication/siwe.js"
184+ ) ;
184185 return siweAuthenticate ( {
185186 client : this . client ,
186187 wallet : params . wallet ,
@@ -199,6 +200,7 @@ export class InAppNativeConnector implements InAppConnector {
199200 case "line" :
200201 case "x" :
201202 case "apple" : {
203+ const { socialAuth } = await import ( "./auth/native-auth.js" ) ;
202204 const ExpoLinking = require ( "expo-linking" ) ;
203205 const redirectUrl =
204206 params . redirectUrl || ( ExpoLinking . createURL ( "" ) as string ) ;
@@ -210,18 +212,24 @@ export class InAppNativeConnector implements InAppConnector {
210212 }
211213 case "passkey" :
212214 return this . passkeyAuth ( params ) ;
213- case "jwt" :
215+ case "jwt" : {
216+ const { customJwt } = await import ( "../core/authentication/jwt.js" ) ;
214217 return customJwt ( {
215218 jwt : params . jwt ,
216219 client : this . client ,
217220 ecosystem : this . ecosystem ,
218221 } ) ;
219- case "auth_endpoint" :
222+ }
223+ case "auth_endpoint" : {
224+ const { authEndpoint } = await import (
225+ "../core/authentication/authEndpoint.js"
226+ ) ;
220227 return authEndpoint ( {
221228 payload : params . payload ,
222229 client : this . client ,
223230 ecosystem : this . ecosystem ,
224231 } ) ;
232+ }
225233 default :
226234 throw new Error ( `Unsupported authentication type: ${ strategy } ` ) ;
227235 }
@@ -287,6 +295,9 @@ export class InAppNativeConnector implements InAppConnector {
287295 let authToken : AuthStoredTokenWithCookieReturnType ;
288296
289297 if ( type === "sign-up" ) {
298+ const { registerPasskey } = await import (
299+ "../core/authentication/passkeys.js"
300+ ) ;
290301 authToken = await registerPasskey ( {
291302 client,
292303 ecosystem,
@@ -299,6 +310,9 @@ export class InAppNativeConnector implements InAppConnector {
299310 } ,
300311 } ) ;
301312 } else {
313+ const { loginWithPasskey } = await import (
314+ "../core/authentication/passkeys.js"
315+ ) ;
302316 authToken = await loginWithPasskey ( {
303317 client,
304318 ecosystem,
@@ -325,20 +339,25 @@ export class InAppNativeConnector implements InAppConnector {
325339
326340 // TODO (rn) expose in the interface
327341 async deleteActiveAccount ( ) {
342+ const { deleteActiveAccount } = await import ( "./auth/native-auth.js" ) ;
328343 return deleteActiveAccount ( {
329344 client : this . client ,
330345 storage : this . storage ,
331346 } ) ;
332347 }
333348
334- logout ( ) : Promise < LogoutReturnType > {
349+ async logout ( ) : Promise < LogoutReturnType > {
350+ const { logoutUser } = await import ( "./helpers/auth/logout.js" ) ;
335351 return logoutUser ( {
336352 client : this . client ,
337353 storage : this . storage ,
338354 } ) ;
339355 }
340356
341357 async linkProfile ( args : AuthArgsType ) {
358+ const { linkAccount } = await import (
359+ "../core/authentication/linkAccount.js"
360+ ) ;
342361 const { storedToken } = await this . authenticate ( args ) ;
343362 return await linkAccount ( {
344363 client : args . client ,
@@ -349,6 +368,9 @@ export class InAppNativeConnector implements InAppConnector {
349368 }
350369
351370 async unlinkProfile ( profile : Profile ) {
371+ const { unlinkAccount } = await import (
372+ "../core/authentication/linkAccount.js"
373+ ) ;
352374 return await unlinkAccount ( {
353375 client : this . client ,
354376 ecosystem : this . ecosystem ,
@@ -358,6 +380,9 @@ export class InAppNativeConnector implements InAppConnector {
358380 }
359381
360382 async getProfiles ( ) {
383+ const { getLinkedProfilesInternal } = await import (
384+ "../core/authentication/linkAccount.js"
385+ ) ;
361386 return getLinkedProfilesInternal ( {
362387 client : this . client ,
363388 ecosystem : this . ecosystem ,
0 commit comments