diff --git a/Content/BlueprintSampleContent/ImtblAuthenticatedWidget4_26.uasset b/Content/BlueprintSampleContent/ImtblAuthenticatedWidget4_26.uasset index b50091ee..b0c8f908 100644 Binary files a/Content/BlueprintSampleContent/ImtblAuthenticatedWidget4_26.uasset and b/Content/BlueprintSampleContent/ImtblAuthenticatedWidget4_26.uasset differ diff --git a/Content/BlueprintSampleContent/ImtblUnauthenticatedWidget4_26.uasset b/Content/BlueprintSampleContent/ImtblUnauthenticatedWidget4_26.uasset index 7a20f426..065a7ba1 100644 Binary files a/Content/BlueprintSampleContent/ImtblUnauthenticatedWidget4_26.uasset and b/Content/BlueprintSampleContent/ImtblUnauthenticatedWidget4_26.uasset differ diff --git a/Source/Immutable/Private/Immutable/Actions/ImtblConnectImxAsyncAction.cpp b/Source/Immutable/Private/Immutable/Actions/ImtblConnectImxAsyncAction.cpp index 4dbbcbfe..14428fb7 100644 --- a/Source/Immutable/Private/Immutable/Actions/ImtblConnectImxAsyncAction.cpp +++ b/Source/Immutable/Private/Immutable/Actions/ImtblConnectImxAsyncAction.cpp @@ -7,29 +7,7 @@ #include "Immutable/Misc/ImtblLogging.h" -UImtblConnectionAsyncActions* UImtblConnectionAsyncActions::Login(UObject* WorldContextObject, bool UseCachedSession) -{ - UImtblConnectionAsyncActions* PassportInitBlueprintNode = NewObject(); - - PassportInitBlueprintNode->WorldContextObject = WorldContextObject; - PassportInitBlueprintNode->bUseCachedSession = UseCachedSession; - PassportInitBlueprintNode->bIsConnectImx = false; - - return PassportInitBlueprintNode; -} - -UImtblConnectionAsyncActions* UImtblConnectionAsyncActions::ConnectImx(UObject* WorldContextObject, bool UseCachedSession) -{ - UImtblConnectionAsyncActions* PassportInitBlueprintNode = NewObject(); - - PassportInitBlueprintNode->WorldContextObject = WorldContextObject; - PassportInitBlueprintNode->bUseCachedSession = UseCachedSession; - PassportInitBlueprintNode->bIsConnectImx = true; - - return PassportInitBlueprintNode; -} - -UImtblConnectionAsyncActions* UImtblConnectionAsyncActions::LoginPKCE(UObject* WorldContextObject) +UImtblConnectionAsyncActions* UImtblConnectionAsyncActions::Login(UObject* WorldContextObject) { UImtblConnectionAsyncActions* PassportInitBlueprintNode = NewObject(); @@ -40,7 +18,7 @@ UImtblConnectionAsyncActions* UImtblConnectionAsyncActions::LoginPKCE(UObject* W return PassportInitBlueprintNode; } -UImtblConnectionAsyncActions* UImtblConnectionAsyncActions::ConnectImxPKCE(UObject* WorldContextObject) +UImtblConnectionAsyncActions* UImtblConnectionAsyncActions::ConnectImx(UObject* WorldContextObject) { UImtblConnectionAsyncActions* PassportInitBlueprintNode = NewObject(); @@ -74,13 +52,9 @@ void UImtblConnectionAsyncActions::DoConnect(TWeakObjectPtr J if (bIsPKCE) { #if PLATFORM_ANDROID | PLATFORM_IOS | PLATFORM_MAC | PLATFORM_WINDOWS - Passport->ConnectPKCE(bIsConnectImx, UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject(this, &UImtblConnectionAsyncActions::OnConnect)); + Passport->Connect(bIsConnectImx, UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject(this, &UImtblConnectionAsyncActions::OnConnect)); #endif } - else - { - Passport->Connect(bIsConnectImx, bUseCachedSession, UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject(this, &UImtblConnectionAsyncActions::OnConnect)); - } } else { diff --git a/Source/Immutable/Private/Immutable/ImmutableDataTypes.cpp b/Source/Immutable/Private/Immutable/ImmutableDataTypes.cpp index 279c593a..c9a78a76 100644 --- a/Source/Immutable/Private/Immutable/ImmutableDataTypes.cpp +++ b/Source/Immutable/Private/Immutable/ImmutableDataTypes.cpp @@ -29,18 +29,7 @@ FString FImmutablePassportInitData::ToJsonString() const return OutString; } -TOptional FImmutablePassportInitDeviceFlowData::FromJsonString(const FString& JsonObjectString) -{ - FImmutablePassportInitDeviceFlowData PassportConnect; - if (!FJsonObjectConverter::JsonObjectStringToUStruct(JsonObjectString, &PassportConnect, 0, 0)) - { - IMTBL_WARN("Could not parse response from JavaScript into the expected " "Passport connect format") - return TOptional(); - } - - return PassportConnect; -} FString FImmutablePassportZkEvmRequestAccountsData::ToJsonString() const { diff --git a/Source/Immutable/Private/Immutable/ImmutablePassport.cpp b/Source/Immutable/Private/Immutable/ImmutablePassport.cpp index 0b2d9fbf..181c69ae 100644 --- a/Source/Immutable/Private/Immutable/ImmutablePassport.cpp +++ b/Source/Immutable/Private/Immutable/ImmutablePassport.cpp @@ -86,26 +86,8 @@ void UImmutablePassport::Initialize(const FImtblPassportResponseDelegate& Respon CallJS(ImmutablePassportAction::INIT, InitData.ToJsonString(), ResponseDelegate, FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::OnInitializeResponse), false); } -void UImmutablePassport::Connect(bool IsConnectImx, bool TryToRelogin, const FImtblPassportResponseDelegate& ResponseDelegate) -{ - SetStateFlags(IPS_CONNECTING); - if (IsConnectImx) - { - SetStateFlags(IPS_IMX); - } - if (TryToRelogin) - { - CallJS(IsConnectImx ? ImmutablePassportAction::RECONNECT : ImmutablePassportAction::RELOGIN, TEXT(""), ResponseDelegate, FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::ReinstateConnection)); - } - else - { - Analytics->Track(IsConnectImx ? UImmutableAnalytics::EEventName::START_CONNECT_IMX : UImmutableAnalytics::EEventName::START_LOGIN); - CallJS(ImmutablePassportAction::INIT_DEVICE_FLOW, TEXT(""), ResponseDelegate, FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::OnInitDeviceFlowResponse)); - } -} - #if PLATFORM_ANDROID | PLATFORM_IOS | PLATFORM_MAC | PLATFORM_WINDOWS -void UImmutablePassport::ConnectPKCE(bool IsConnectImx, const FImtblPassportResponseDelegate& ResponseDelegate) +void UImmutablePassport::Connect(bool IsConnectImx, const FImtblPassportResponseDelegate& ResponseDelegate) { SetStateFlags(IPS_CONNECTING | IPS_PKCE); @@ -126,7 +108,7 @@ void UImmutablePassport::ConnectPKCE(bool IsConnectImx, const FImtblPassportResp } PKCEResponseDelegate = ResponseDelegate; Analytics->Track(IsConnectImx ? UImmutableAnalytics::EEventName::START_CONNECT_IMX_PKCE : UImmutableAnalytics::EEventName::START_LOGIN_PKCE); - CallJS(ImmutablePassportAction::GetPKCEAuthUrl, TEXT(""), PKCEResponseDelegate, FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::OnGetPKCEAuthUrlResponse)); + CallJS(ImmutablePassportAction::GetPKCEAuthUrl, TEXT(""), PKCEResponseDelegate, FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::OnGetAuthUrlResponse)); } #endif @@ -198,13 +180,7 @@ void UImmutablePassport::ZkEvmSignTypedDataV4(const FString& RequestJsonString, CallJS(ImmutablePassportAction::ZkEvmSignTypedDataV4, RequestJsonString, ResponseDelegate, FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::OnBridgeCallbackResponse)); } -void UImmutablePassport::ConfirmCode(const FString& DeviceCode, const float Interval, const FImtblPassportResponseDelegate& ResponseDelegate) -{ - FImmutablePassportCodeConfirmRequestData Data{DeviceCode, Interval}; - FString Action = IsStateFlagsSet(IPS_IMX) ? ImmutablePassportAction::CONNECT_CONFIRM_CODE : ImmutablePassportAction::LOGIN_CONFIRM_CODE; - CallJS(Action, UStructToJsonString(Data), ResponseDelegate, FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::OnConfirmCodeResponse)); -} void UImmutablePassport::GetIdToken(const FImtblPassportResponseDelegate& ResponseDelegate) { @@ -347,40 +323,7 @@ void UImmutablePassport::Setup(const TWeakObjectPtr Connector Analytics->Setup(Connector); } -void UImmutablePassport::ReinstateConnection(FImtblJSResponse Response) -{ - ResetStateFlags(IPS_CONNECTING); - - if (auto ResponseDelegate = GetResponseDelegate(Response)) - { - // currently, this response has to be called only for RELOGIN AND RECONNECT bridge routines - bool IsRelogin = Response.responseFor.Compare(ImmutablePassportAction::RELOGIN, ESearchCase::IgnoreCase) == 0; - const FString CallbackName = IsRelogin ? "Relogin" : "Reconnect"; - UImmutableAnalytics::EEventName EventName = IsRelogin ? UImmutableAnalytics::EEventName::COMPLETE_RELOGIN : UImmutableAnalytics::EEventName::COMPLETE_RECONNECT; - if (Response.success) - { - SetStateFlags(IPS_CONNECTED); - ResponseDelegate->ExecuteIfBound(FImmutablePassportResult{true, "", Response}); - Analytics->Track(EventName, true); - } - else - { - Analytics->Track(EventName, false); -#if PLATFORM_ANDROID | PLATFORM_IOS | PLATFORM_MAC - if (IsStateFlagsSet(IPS_PKCE)) - { - PKCEResponseDelegate = ResponseDelegate.GetValue(); - CallJS(ImmutablePassportAction::GetPKCEAuthUrl, TEXT(""), PKCEResponseDelegate, FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::OnGetPKCEAuthUrlResponse)); - } - else -#endif - { - CallJS(ImmutablePassportAction::INIT_DEVICE_FLOW, TEXT(""), ResponseDelegate.GetValue(), FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::OnInitDeviceFlowResponse)); - } - } - } -} bool UImmutablePassport::CheckIsInitialized(const FString& Action, const FImtblPassportResponseDelegate& ResponseDelegate) const { @@ -436,36 +379,7 @@ void UImmutablePassport::OnInitializeResponse(FImtblJSResponse Response) } } -void UImmutablePassport::OnInitDeviceFlowResponse(FImtblJSResponse Response) -{ - if (auto ResponseDelegate = GetResponseDelegate(Response)) - { - const auto InitDeviceFlowData = JsonObjectToUStruct(Response.JsonObject); - if (!Response.success || !InitDeviceFlowData || !InitDeviceFlowData->code.Len()) - { - FString Msg; - - IMTBL_WARN("Login device flow initialization attempt failed."); - Response.Error.IsSet() ? Msg = Response.Error->ToString() : Msg = Response.JsonObject->GetStringField(TEXT("error")); - ResponseDelegate->ExecuteIfBound(FImmutablePassportResult{false, Msg, Response}); - - return; - } - FString Err; - - FPlatformProcess::LaunchURL(*InitDeviceFlowData->url, nullptr, &Err); - if (Err.Len()) - { - FString Msg = "Failed to connect to Browser: " + Err; - - IMTBL_ERR("%s", *Msg); - ResponseDelegate->ExecuteIfBound(FImmutablePassportResult{false, Msg, Response}); - return; - } - ConfirmCode(InitDeviceFlowData->deviceCode, InitDeviceFlowData->interval, ResponseDelegate.GetValue()); - } -} void UImmutablePassport::OnLogoutResponse(FImtblJSResponse Response) { @@ -521,30 +435,15 @@ void UImmutablePassport::OnLogoutResponse(FImtblJSResponse Response) if (!Url.IsEmpty()) { -#if PLATFORM_ANDROID | PLATFORM_IOS | PLATFORM_MAC | PLATFORM_WINDOWS - if (IsStateFlagsSet(IPS_PKCE)) - { - OnHandleDeepLink.AddUObject(this, &UImmutablePassport::OnDeepLinkActivated); + OnHandleDeepLink.AddUObject(this, &UImmutablePassport::OnDeepLinkActivated); #if PLATFORM_ANDROID - LaunchAndroidUrl(Url); + LaunchAndroidUrl(Url); #elif PLATFORM_IOS - [[ImmutableIOS instance] launchUrl:TCHAR_TO_ANSI(*Url)]; + [[ImmutableIOS instance] launchUrl:TCHAR_TO_ANSI(*Url)]; #elif PLATFORM_MAC - [[ImmutableMac instance] launchUrl:TCHAR_TO_ANSI(*Url) forRedirectUri:TCHAR_TO_ANSI(*InitData.logoutRedirectUri)]; -#endif -#if PLATFORM_WINDOWS - Logout(Response); -#endif - } - else - { -#endif - Logout(Response); - Analytics->Track(UImmutableAnalytics::EEventName::COMPLETE_LOGOUT); - IMTBL_LOG("Logged out") - ResponseDelegate->ExecuteIfBound(FImmutablePassportResult{ Response.success }); -#if PLATFORM_ANDROID | PLATFORM_IOS | PLATFORM_MAC | PLATFORM_WINDOWS - } + [[ImmutableMac instance] launchUrl:TCHAR_TO_ANSI(*Url) forRedirectUri:TCHAR_TO_ANSI(*InitData.logoutRedirectUri)]; +#elif PLATFORM_WINDOWS + Logout(Response); #endif } else @@ -555,7 +454,7 @@ void UImmutablePassport::OnLogoutResponse(FImtblJSResponse Response) } #if PLATFORM_ANDROID | PLATFORM_IOS | PLATFORM_MAC | PLATFORM_WINDOWS -void UImmutablePassport::OnGetPKCEAuthUrlResponse(FImtblJSResponse Response) +void UImmutablePassport::OnGetAuthUrlResponse(FImtblJSResponse Response) { if (PKCEResponseDelegate.IsBound()) { @@ -573,7 +472,7 @@ void UImmutablePassport::OnGetPKCEAuthUrlResponse(FImtblJSResponse Response) Msg = Response.JsonObject->GetStringField(TEXT("result")).Replace(TEXT(" "), TEXT("+")); #if PLATFORM_ANDROID - OnPKCEDismissed = FImtblPassportOnPKCEDismissedDelegate::CreateUObject(this, &UImmutablePassport::HandleOnLoginPKCEDismissed); + OnPKCEDismissed = FImtblPassportOnPKCEDismissedDelegate::CreateUObject(this, &UImmutablePassport::HandleOnLoginDismissed); LaunchAndroidUrl(Msg); #elif PLATFORM_IOS [[ImmutableIOS instance] launchUrl:TCHAR_TO_ANSI(*Msg)]; @@ -599,7 +498,7 @@ void UImmutablePassport::OnGetPKCEAuthUrlResponse(FImtblJSResponse Response) } } -void UImmutablePassport::OnConnectPKCEResponse(FImtblJSResponse Response) +void UImmutablePassport::OnConnectResponse(FImtblJSResponse Response) { if (PKCEResponseDelegate.IsBound()) { @@ -632,29 +531,7 @@ void UImmutablePassport::OnConnectPKCEResponse(FImtblJSResponse Response) ResetStateFlags(IPS_COMPLETING_PKCE); } -void UImmutablePassport::OnConfirmCodeResponse(FImtblJSResponse Response) -{ - if (auto ResponseDelegate = GetResponseDelegate(Response)) - { - FString Msg; - FString TypeOfConnection = IsStateFlagsSet(IPS_IMX) ? TEXT("connect") : TEXT("login"); - UImmutableAnalytics::EEventName EventName = IsStateFlagsSet(IPS_IMX) ? UImmutableAnalytics::EEventName::COMPLETE_CONNECT_IMX : UImmutableAnalytics::EEventName::COMPLETE_LOGIN; - ResetStateFlags(IPS_CONNECTING); - if (Response.success) - { - IMTBL_LOG("Code confirmed for %s operation.", *TypeOfConnection) - SetStateFlags(IPS_CONNECTED); - } - else - { - IMTBL_LOG("%s code not confirmed.", *TypeOfConnection) - Response.Error.IsSet() ? Msg = Response.Error->ToString() : Msg = Response.JsonObject->GetStringField(TEXT("error")); - } - Analytics->Track(EventName, Response.success); - ResponseDelegate->ExecuteIfBound(FImmutablePassportResult{Response.success, Msg, Response}); - } -} void UImmutablePassport::OnBridgeCallbackResponse(FImtblJSResponse Response) { @@ -724,6 +601,7 @@ void UImmutablePassport::OnDeepLinkActivated(const FString& DeepLink) FGraphEventRef GameThreadTask = FFunctionGraphTask::CreateAndDispatchWhenReady([this]() { Analytics->Track(UImmutableAnalytics::EEventName::COMPLETE_LOGOUT_PKCE); + IMTBL_LOG("Complete Logout PKCE") PKCELogoutResponseDelegate.ExecuteIfBound(FImmutablePassportResult{true, "Logged out"}); PKCELogoutResponseDelegate = nullptr; ResetStateFlags(IPS_CONNECTED | IPS_PKCE | IPS_IMX); @@ -733,13 +611,13 @@ void UImmutablePassport::OnDeepLinkActivated(const FString& DeepLink) } else if (DeepLink.StartsWith(InitData.redirectUri)) { - CompleteLoginPKCEFlow(DeepLink); + CompleteLoginFlow(DeepLink); } PKCEData = nullptr; } -void UImmutablePassport::CompleteLoginPKCEFlow(FString Url) +void UImmutablePassport::CompleteLoginFlow(FString Url) { // Required mainly for Android to detect when Chrome Custom tabs is dismissed // See HandleOnLoginPKCEDismissed @@ -780,10 +658,10 @@ void UImmutablePassport::CompleteLoginPKCEFlow(FString Url) } else { - FImmutablePassportConnectPKCEData Data = FImmutablePassportConnectPKCEData{Code.GetValue(), State.GetValue()}; + FImmutablePassportConnectData Data = FImmutablePassportConnectData{Code.GetValue(), State.GetValue()}; CallJS(IsStateFlagsSet(IPS_IMX) ? ImmutablePassportAction::CONNECT_PKCE : ImmutablePassportAction::LOGIN_PKCE, UStructToJsonString(Data), PKCEResponseDelegate, - FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::OnConnectPKCEResponse)); + FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::OnConnectResponse)); } } #endif @@ -812,7 +690,7 @@ void UImmutablePassport::HandleDeepLink(NSString* sDeepLink) const } #if PLATFORM_ANDROID -void UImmutablePassport::HandleOnLoginPKCEDismissed() +void UImmutablePassport::HandleOnLoginDismissed() { IMTBL_LOG("Handle On Login PKCE Dismissed"); OnPKCEDismissed = nullptr; diff --git a/Source/Immutable/Public/Immutable/Actions/ImtblConnectImxAsyncAction.h b/Source/Immutable/Public/Immutable/Actions/ImtblConnectImxAsyncAction.h index 5298bd98..6de45f3d 100644 --- a/Source/Immutable/Public/Immutable/Actions/ImtblConnectImxAsyncAction.h +++ b/Source/Immutable/Public/Immutable/Actions/ImtblConnectImxAsyncAction.h @@ -19,52 +19,29 @@ class IMMUTABLE_API UImtblConnectionAsyncActions : public UImtblBlueprintAsyncAc public: /** - * Log into Passport using Device Code Authorisation. + * Log into Passport * * @param WorldContextObject World context - * @param UseCachedSession Whether to use stored credentials for relogin * * @return A reference to the object represented by this node */ UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject", BlueprintInternalUseOnly = "true"), Category = "Immutable") - static UImtblConnectionAsyncActions* Login(UObject* WorldContextObject, bool UseCachedSession = false); + static UImtblConnectionAsyncActions* Login(UObject* WorldContextObject); /** - * Log into Passport using Device Code Authorisation, initialise the gamer's wallet and instantiate the IMX provider. + * Log into Passport, initialise the gamer's wallet and instantiate the IMX provider. * * @param WorldContextObject World context - * @param UseCachedSession Whether to use stored credentials for relogin * * @return A reference to the object represented by this node */ UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject", BlueprintInternalUseOnly = "true"), Category = "Immutable") - static UImtblConnectionAsyncActions* ConnectImx(UObject* WorldContextObject, bool UseCachedSession = false); - - /** - * Log into Passport using PKCE - * - * @param WorldContextObject World context - * - * @return A reference to the object represented by this node - */ - UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject", BlueprintInternalUseOnly = "true"), Category = "Immutable") - static UImtblConnectionAsyncActions* LoginPKCE(UObject* WorldContextObject); - - /** - * Log into Passport using PKCE, initialise the gamer's wallet and instantiate the IMX provider. - * - * @param WorldContextObject World context - * - * @return A reference to the object represented by this node - */ - UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject", BlueprintInternalUseOnly = "true"), Category = "Immutable") - static UImtblConnectionAsyncActions* ConnectImxPKCE(UObject* WorldContextObject); + static UImtblConnectionAsyncActions* ConnectImx(UObject* WorldContextObject); virtual void Activate() override; private: - FImmutablePassportInitDeviceFlowData InitDeviceFlowData; void DoConnect(TWeakObjectPtr JSConnector); void OnConnect(FImmutablePassportResult Result); diff --git a/Source/Immutable/Public/Immutable/ImmutableDataTypes.h b/Source/Immutable/Public/Immutable/ImmutableDataTypes.h index 88b904a3..ef9cf1ae 100644 --- a/Source/Immutable/Public/Immutable/ImmutableDataTypes.h +++ b/Source/Immutable/Public/Immutable/ImmutableDataTypes.h @@ -91,26 +91,6 @@ struct IMMUTABLE_API FImmutablePassportInitData FString ToJsonString() const; }; -USTRUCT() -struct FImmutablePassportInitDeviceFlowData -{ - GENERATED_BODY() - - UPROPERTY() - FString code; - - UPROPERTY() - FString deviceCode; - - UPROPERTY() - FString url; - - UPROPERTY() - float interval = 0; - - static TOptional FromJsonString(const FString& JsonObjectString); -}; - USTRUCT() struct FImtblUserProfile { @@ -153,23 +133,10 @@ struct IMMUTABLE_API FImmutablePassportZkEvmGetBalanceData FString ToJsonString() const; }; -USTRUCT() -struct FImmutablePassportCodeConfirmRequestData -{ - GENERATED_BODY() - UPROPERTY() - FString deviceCode; - - UPROPERTY() - float interval = 5; - - UPROPERTY() - float timeoutMs = 15 * 60 * 1000; -}; USTRUCT() -struct FImmutablePassportConnectPKCEData +struct FImmutablePassportConnectData { GENERATED_BODY() diff --git a/Source/Immutable/Public/Immutable/ImmutableNames.h b/Source/Immutable/Public/Immutable/ImmutableNames.h index 79ba24fa..66471b21 100644 --- a/Source/Immutable/Public/Immutable/ImmutableNames.h +++ b/Source/Immutable/Public/Immutable/ImmutableNames.h @@ -3,11 +3,6 @@ namespace ImmutablePassportAction { const FString INIT = TEXT("init"); - const FString INIT_DEVICE_FLOW = TEXT("initDeviceFlow"); - const FString RELOGIN = TEXT("relogin"); - const FString LOGIN_CONFIRM_CODE = TEXT("loginConfirmCode"); - const FString CONNECT_CONFIRM_CODE = TEXT("connectConfirmCode"); - const FString RECONNECT = TEXT("reconnect"); const FString Logout = TEXT("logout"); const FString Connect = TEXT("connect"); const FString ConnectEvm = TEXT("connectEvm"); diff --git a/Source/Immutable/Public/Immutable/ImmutablePassport.h b/Source/Immutable/Public/Immutable/ImmutablePassport.h index 004e0471..37646a33 100644 --- a/Source/Immutable/Public/Immutable/ImmutablePassport.h +++ b/Source/Immutable/Public/Immutable/ImmutablePassport.h @@ -96,25 +96,15 @@ class IMMUTABLE_API UImmutablePassport : public UObject */ void Initialize(const FImtblPassportResponseDelegate& ResponseDelegate); - /** - * Logs the user into Passport via device code auth and sets up the Immutable X provider. - * - * This will open the user's default browser and take them through Passport login. - * @param IsConnectImx If true, the "re-connect" method is used to authenticate into Passport with Immutable X. - * Else, "re-login" is used for authentication. To access a wallet with Immutable X or zkEVM later, you must call "Connect" again with this value set to true, or use "ConnectEvm." - * @param TryToRelogin If true, the game bridge will use a cached session to re-connect or re-login the user, avoiding the need to open a web browser. If this attempt fails, it will fall back to device code authentication. - * @param ResponseDelegate Callback delegate. - */ - void Connect(bool IsConnectImx, bool TryToRelogin, const FImtblPassportResponseDelegate& ResponseDelegate); #if PLATFORM_ANDROID | PLATFORM_IOS | PLATFORM_MAC | PLATFORM_WINDOWS /** * Logs into Passport using Authorisation Code Flow with Proof Key for Code Exchange (PKCE) * - * @param IsConnectImx If true, player will go through the device code auth login flow and connect to Immutable X. - * Else, initiate only the device auth login flow. + * @param IsConnectImx If true, player will connect to Immutable X after logging in. + * Else, just perform the login without connecting to Immutable X. * @param ResponseDelegate Callback delegate. */ - void ConnectPKCE(bool IsConnectImx, const FImtblPassportResponseDelegate& ResponseDelegate); + void Connect(bool IsConnectImx, const FImtblPassportResponseDelegate& ResponseDelegate); #endif /** @@ -355,12 +345,7 @@ class IMMUTABLE_API UImmutablePassport : public UObject */ void Setup(TWeakObjectPtr Connector); - /** - * Reinstate the connection based on the provided JavaScript response. - * - * @param Response The JavaScript response object to reinstate the connection. - */ - void ReinstateConnection(FImtblJSResponse Response); + /** * Checks if Passport has been initialised before allowing an action to proceed. @@ -381,14 +366,7 @@ class IMMUTABLE_API UImmutablePassport : public UObject */ TOptional GetResponseDelegate(const FImtblJSResponse& Response); - /** - * Confirms the device code by calling the appropriate JavaScript action. - * - * @param DeviceCode The device code to be confirmed. - * @param Interval The time interval to wait between attempts. - * @param ResponseDelegate A delegate to handle the response from the confirmation request. - */ - void ConfirmCode(const FString& DeviceCode, const float Interval, const FImtblPassportResponseDelegate& ResponseDelegate); + /** * Common callback that handles the responses from game bridge @@ -404,12 +382,7 @@ class IMMUTABLE_API UImmutablePassport : public UObject */ void OnInitializeResponse(FImtblJSResponse Response); - /** - * Callback from init device flow (device code auth login flow). - * - * @param Response The JavaScript response object containing the result of the callback. - */ - void OnInitDeviceFlowResponse(FImtblJSResponse Response); + /** * Callback from logout. @@ -418,12 +391,7 @@ class IMMUTABLE_API UImmutablePassport : public UObject */ void OnLogoutResponse(FImtblJSResponse Response); - /** - * Callback from confirm code. - * - * @param Response The JavaScript response object containing the result of the callback. - */ - void OnConfirmCodeResponse(FImtblJSResponse Response); + // mobile platform callbacks #if PLATFORM_ANDROID | PLATFORM_IOS | PLATFORM_MAC | PLATFORM_WINDOWS @@ -432,21 +400,21 @@ class IMMUTABLE_API UImmutablePassport : public UObject * * @param Response The JavaScript response object containing the result of the callback. */ - void OnGetPKCEAuthUrlResponse(FImtblJSResponse Response); + void OnGetAuthUrlResponse(FImtblJSResponse Response); /* * Callback from Connect PKCE. * * @param Response The JavaScript response object containing the result of the callback. */ - void OnConnectPKCEResponse(FImtblJSResponse Response); + void OnConnectResponse(FImtblJSResponse Response); /* * Completes the PKCE login flow using the provided URL. * * @param Url The URL containing the authorisation code and state. */ - void CompleteLoginPKCEFlow(FString Url); + void CompleteLoginFlow(FString Url); #endif /*