@@ -86,24 +86,6 @@ void UImmutablePassport::Initialize(const FImtblPassportResponseDelegate& Respon
86
86
CallJS (ImmutablePassportAction::INIT, InitData.ToJsonString (), ResponseDelegate, FImtblJSResponseDelegate::CreateUObject (this , &UImmutablePassport::OnInitializeResponse), false );
87
87
}
88
88
89
- void UImmutablePassport::Connect (bool IsConnectImx, bool TryToRelogin, const FImtblPassportResponseDelegate& ResponseDelegate)
90
- {
91
- SetStateFlags (IPS_CONNECTING);
92
- if (IsConnectImx)
93
- {
94
- SetStateFlags (IPS_IMX);
95
- }
96
- if (TryToRelogin)
97
- {
98
- CallJS (IsConnectImx ? ImmutablePassportAction::RECONNECT : ImmutablePassportAction::RELOGIN, TEXT (" " ), ResponseDelegate, FImtblJSResponseDelegate::CreateUObject (this , &UImmutablePassport::ReinstateConnection));
99
- }
100
- else
101
- {
102
- Analytics->Track (IsConnectImx ? UImmutableAnalytics::EEventName::START_CONNECT_IMX : UImmutableAnalytics::EEventName::START_LOGIN);
103
- CallJS (ImmutablePassportAction::INIT_DEVICE_FLOW, TEXT (" " ), ResponseDelegate, FImtblJSResponseDelegate::CreateUObject (this , &UImmutablePassport::OnInitDeviceFlowResponse));
104
- }
105
- }
106
-
107
89
#if PLATFORM_ANDROID | PLATFORM_IOS | PLATFORM_MAC | PLATFORM_WINDOWS
108
90
void UImmutablePassport::ConnectPKCE (bool IsConnectImx, const FImtblPassportResponseDelegate& ResponseDelegate)
109
91
{
@@ -198,13 +180,7 @@ void UImmutablePassport::ZkEvmSignTypedDataV4(const FString& RequestJsonString,
198
180
CallJS (ImmutablePassportAction::ZkEvmSignTypedDataV4, RequestJsonString, ResponseDelegate, FImtblJSResponseDelegate::CreateUObject (this , &UImmutablePassport::OnBridgeCallbackResponse));
199
181
}
200
182
201
- void UImmutablePassport::ConfirmCode (const FString& DeviceCode, const float Interval, const FImtblPassportResponseDelegate& ResponseDelegate)
202
- {
203
- FImmutablePassportCodeConfirmRequestData Data{DeviceCode, Interval};
204
- FString Action = IsStateFlagsSet (IPS_IMX) ? ImmutablePassportAction::CONNECT_CONFIRM_CODE : ImmutablePassportAction::LOGIN_CONFIRM_CODE;
205
183
206
- CallJS (Action, UStructToJsonString (Data), ResponseDelegate, FImtblJSResponseDelegate::CreateUObject (this , &UImmutablePassport::OnConfirmCodeResponse));
207
- }
208
184
209
185
void UImmutablePassport::GetIdToken (const FImtblPassportResponseDelegate& ResponseDelegate)
210
186
{
@@ -347,40 +323,7 @@ void UImmutablePassport::Setup(const TWeakObjectPtr<UImtblJSConnector> Connector
347
323
Analytics->Setup (Connector);
348
324
}
349
325
350
- void UImmutablePassport::ReinstateConnection (FImtblJSResponse Response)
351
- {
352
- ResetStateFlags (IPS_CONNECTING);
353
-
354
- if (auto ResponseDelegate = GetResponseDelegate (Response))
355
- {
356
- // currently, this response has to be called only for RELOGIN AND RECONNECT bridge routines
357
- bool IsRelogin = Response.responseFor .Compare (ImmutablePassportAction::RELOGIN, ESearchCase::IgnoreCase) == 0 ;
358
- const FString CallbackName = IsRelogin ? " Relogin" : " Reconnect" ;
359
- UImmutableAnalytics::EEventName EventName = IsRelogin ? UImmutableAnalytics::EEventName::COMPLETE_RELOGIN : UImmutableAnalytics::EEventName::COMPLETE_RECONNECT;
360
326
361
- if (Response.success )
362
- {
363
- SetStateFlags (IPS_CONNECTED);
364
- ResponseDelegate->ExecuteIfBound (FImmutablePassportResult{true , " " , Response});
365
- Analytics->Track (EventName, true );
366
- }
367
- else
368
- {
369
- Analytics->Track (EventName, false );
370
- #if PLATFORM_ANDROID | PLATFORM_IOS | PLATFORM_MAC
371
- if (IsStateFlagsSet (IPS_PKCE))
372
- {
373
- PKCEResponseDelegate = ResponseDelegate.GetValue ();
374
- CallJS (ImmutablePassportAction::GetPKCEAuthUrl, TEXT (" " ), PKCEResponseDelegate, FImtblJSResponseDelegate::CreateUObject (this , &UImmutablePassport::OnGetPKCEAuthUrlResponse));
375
- }
376
- else
377
- #endif
378
- {
379
- CallJS (ImmutablePassportAction::INIT_DEVICE_FLOW, TEXT (" " ), ResponseDelegate.GetValue (), FImtblJSResponseDelegate::CreateUObject (this , &UImmutablePassport::OnInitDeviceFlowResponse));
380
- }
381
- }
382
- }
383
- }
384
327
385
328
bool UImmutablePassport::CheckIsInitialized (const FString& Action, const FImtblPassportResponseDelegate& ResponseDelegate) const
386
329
{
@@ -436,36 +379,7 @@ void UImmutablePassport::OnInitializeResponse(FImtblJSResponse Response)
436
379
}
437
380
}
438
381
439
- void UImmutablePassport::OnInitDeviceFlowResponse (FImtblJSResponse Response)
440
- {
441
- if (auto ResponseDelegate = GetResponseDelegate (Response))
442
- {
443
- const auto InitDeviceFlowData = JsonObjectToUStruct<FImmutablePassportInitDeviceFlowData>(Response.JsonObject );
444
382
445
- if (!Response.success || !InitDeviceFlowData || !InitDeviceFlowData->code .Len ())
446
- {
447
- FString Msg;
448
-
449
- IMTBL_WARN (" Login device flow initialization attempt failed." );
450
- Response.Error .IsSet () ? Msg = Response.Error ->ToString () : Msg = Response.JsonObject ->GetStringField (TEXT (" error" ));
451
- ResponseDelegate->ExecuteIfBound (FImmutablePassportResult{false , Msg, Response});
452
-
453
- return ;
454
- }
455
- FString Err;
456
-
457
- FPlatformProcess::LaunchURL (*InitDeviceFlowData->url , nullptr , &Err);
458
- if (Err.Len ())
459
- {
460
- FString Msg = " Failed to connect to Browser: " + Err;
461
-
462
- IMTBL_ERR (" %s" , *Msg);
463
- ResponseDelegate->ExecuteIfBound (FImmutablePassportResult{false , Msg, Response});
464
- return ;
465
- }
466
- ConfirmCode (InitDeviceFlowData->deviceCode , InitDeviceFlowData->interval , ResponseDelegate.GetValue ());
467
- }
468
- }
469
383
470
384
void UImmutablePassport::OnLogoutResponse (FImtblJSResponse Response)
471
385
{
@@ -521,30 +435,15 @@ void UImmutablePassport::OnLogoutResponse(FImtblJSResponse Response)
521
435
522
436
if (!Url.IsEmpty ())
523
437
{
524
- #if PLATFORM_ANDROID | PLATFORM_IOS | PLATFORM_MAC | PLATFORM_WINDOWS
525
- if (IsStateFlagsSet (IPS_PKCE))
526
- {
527
- OnHandleDeepLink.AddUObject (this , &UImmutablePassport::OnDeepLinkActivated);
438
+ OnHandleDeepLink.AddUObject (this , &UImmutablePassport::OnDeepLinkActivated);
528
439
#if PLATFORM_ANDROID
529
- LaunchAndroidUrl (Url);
440
+ LaunchAndroidUrl (Url);
530
441
#elif PLATFORM_IOS
531
- [[ImmutableIOS instance] launchUrl:TCHAR_TO_ANSI (*Url)];
442
+ [[ImmutableIOS instance] launchUrl:TCHAR_TO_ANSI (*Url)];
532
443
#elif PLATFORM_MAC
533
- [[ImmutableMac instance] launchUrl:TCHAR_TO_ANSI (*Url) forRedirectUri:TCHAR_TO_ANSI (*InitData.logoutRedirectUri )];
534
- #endif
535
- #if PLATFORM_WINDOWS
536
- Logout (Response);
537
- #endif
538
- }
539
- else
540
- {
541
- #endif
542
- Logout (Response);
543
- Analytics->Track (UImmutableAnalytics::EEventName::COMPLETE_LOGOUT);
544
- IMTBL_LOG (" Logged out" )
545
- ResponseDelegate->ExecuteIfBound (FImmutablePassportResult{ Response.success });
546
- #if PLATFORM_ANDROID | PLATFORM_IOS | PLATFORM_MAC | PLATFORM_WINDOWS
547
- }
444
+ [[ImmutableMac instance] launchUrl:TCHAR_TO_ANSI (*Url) forRedirectUri:TCHAR_TO_ANSI (*InitData.logoutRedirectUri )];
445
+ #elif PLATFORM_WINDOWS
446
+ Logout (Response);
548
447
#endif
549
448
}
550
449
else
@@ -632,29 +531,7 @@ void UImmutablePassport::OnConnectPKCEResponse(FImtblJSResponse Response)
632
531
ResetStateFlags (IPS_COMPLETING_PKCE);
633
532
}
634
533
635
- void UImmutablePassport::OnConfirmCodeResponse (FImtblJSResponse Response)
636
- {
637
- if (auto ResponseDelegate = GetResponseDelegate (Response))
638
- {
639
- FString Msg;
640
- FString TypeOfConnection = IsStateFlagsSet (IPS_IMX) ? TEXT (" connect" ) : TEXT (" login" );
641
- UImmutableAnalytics::EEventName EventName = IsStateFlagsSet (IPS_IMX) ? UImmutableAnalytics::EEventName::COMPLETE_CONNECT_IMX : UImmutableAnalytics::EEventName::COMPLETE_LOGIN;
642
534
643
- ResetStateFlags (IPS_CONNECTING);
644
- if (Response.success )
645
- {
646
- IMTBL_LOG (" Code confirmed for %s operation." , *TypeOfConnection)
647
- SetStateFlags (IPS_CONNECTED);
648
- }
649
- else
650
- {
651
- IMTBL_LOG (" %s code not confirmed." , *TypeOfConnection)
652
- Response.Error .IsSet () ? Msg = Response.Error ->ToString () : Msg = Response.JsonObject ->GetStringField (TEXT (" error" ));
653
- }
654
- Analytics->Track (EventName, Response.success );
655
- ResponseDelegate->ExecuteIfBound (FImmutablePassportResult{Response.success , Msg, Response});
656
- }
657
- }
658
535
659
536
void UImmutablePassport::OnBridgeCallbackResponse (FImtblJSResponse Response)
660
537
{
@@ -724,6 +601,7 @@ void UImmutablePassport::OnDeepLinkActivated(const FString& DeepLink)
724
601
FGraphEventRef GameThreadTask = FFunctionGraphTask::CreateAndDispatchWhenReady ([this ]()
725
602
{
726
603
Analytics->Track (UImmutableAnalytics::EEventName::COMPLETE_LOGOUT_PKCE);
604
+ IMTBL_LOG (" Complete Logout PKCE" )
727
605
PKCELogoutResponseDelegate.ExecuteIfBound (FImmutablePassportResult{true , " Logged out" });
728
606
PKCELogoutResponseDelegate = nullptr ;
729
607
ResetStateFlags (IPS_CONNECTED | IPS_PKCE | IPS_IMX);
0 commit comments