@@ -182,6 +182,33 @@ class Latte(
182182 return Pair (fragment, handle)
183183 }
184184
185+ suspend fun reauthenticateV2 (
186+ context : Context ,
187+ coroutineScope : CoroutineScope ,
188+ options : ReauthenticateV2Options
189+ ): Pair <Fragment , LatteHandle <UserInfo >> {
190+ val request = authgear.createReauthenticateRequest(makeAuthgearReauthenticateOptionsV2(context, options))
191+ val fragment = LatteFragment .makeWithPreCreatedWebView(
192+ context = context,
193+ id = makeID(),
194+ url = request.url,
195+ redirectUri = request.redirectUri,
196+ webContentsDebuggingEnabled = webContentsDebuggingEnabled
197+ )
198+
199+ val listenHandle = fragment.listen(authgear.core.application, this )
200+ fragment.waitWebViewToLoad(webViewLoadTimeoutMillis)
201+
202+ val d = coroutineScope.async {
203+ val result = waitForResult(listenHandle)
204+ val userInfo = authgear.finishReauthentication(result.getOrThrow().toString(), request)
205+ userInfo
206+ }
207+
208+ val handle = LatteHandle (fragment.latteID, d)
209+ return Pair (fragment, handle)
210+ }
211+
185212 suspend fun verifyEmail (
186213 context : Context ,
187214 coroutineScope : CoroutineScope ,
@@ -571,4 +598,22 @@ class Latte(
571598 uiLocales = latteOptions.uiLocales
572599 )
573600 }
601+
602+ private suspend fun makeAuthgearReauthenticateOptionsV2 (context : Context , latteOptions : ReauthenticateV2Options ): com.oursky.authgear.ReauthenticateOptions {
603+ val reauthXState = HashMap (latteOptions.xState)
604+ reauthXState[" user_initiate" ] = " reauthv2"
605+
606+ val reauthXSecrets = hashMapOf(
607+ " email" to latteOptions.email,
608+ " phone" to latteOptions.phone
609+ )
610+
611+ val finalXState = makeXStateWithSecrets(reauthXState, reauthXSecrets)
612+
613+ return ReauthenticateOptions (
614+ xState = finalXState.toQueryParameter(),
615+ redirectUri = " latte://complete" ,
616+ uiLocales = latteOptions.uiLocales
617+ )
618+ }
574619}
0 commit comments