Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,26 @@
#include "Immutable/Misc/ImtblLogging.h"


UImtblConnectionAsyncActions* UImtblConnectionAsyncActions::Login(UObject* WorldContextObject)
UImtblConnectionAsyncActions* UImtblConnectionAsyncActions::Login(UObject* WorldContextObject, EImmutableDirectLoginMethod DirectLoginMethod)
{
UImtblConnectionAsyncActions* PassportInitBlueprintNode = NewObject<UImtblConnectionAsyncActions>();

PassportInitBlueprintNode->WorldContextObject = WorldContextObject;
PassportInitBlueprintNode->bIsConnectImx = false;
PassportInitBlueprintNode->bIsPKCE = true;
PassportInitBlueprintNode->DirectLoginMethod = DirectLoginMethod;

return PassportInitBlueprintNode;
}

UImtblConnectionAsyncActions* UImtblConnectionAsyncActions::ConnectImx(UObject* WorldContextObject)
UImtblConnectionAsyncActions* UImtblConnectionAsyncActions::ConnectImx(UObject* WorldContextObject, EImmutableDirectLoginMethod DirectLoginMethod)
{
UImtblConnectionAsyncActions* PassportInitBlueprintNode = NewObject<UImtblConnectionAsyncActions>();

PassportInitBlueprintNode->WorldContextObject = WorldContextObject;
PassportInitBlueprintNode->bIsConnectImx = true;
PassportInitBlueprintNode->bIsPKCE = true;
PassportInitBlueprintNode->DirectLoginMethod = DirectLoginMethod;

return PassportInitBlueprintNode;
}
Expand Down Expand Up @@ -52,7 +54,7 @@ void UImtblConnectionAsyncActions::DoConnect(TWeakObjectPtr<UImtblJSConnector> J
if (bIsPKCE)
{
#if PLATFORM_ANDROID | PLATFORM_IOS | PLATFORM_MAC | PLATFORM_WINDOWS
Passport->Connect(bIsConnectImx, UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject(this, &UImtblConnectionAsyncActions::OnConnect));
Passport->Connect(bIsConnectImx, UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject(this, &UImtblConnectionAsyncActions::OnConnect), DirectLoginMethod);
#endif
}
}
Expand Down
33 changes: 30 additions & 3 deletions Source/Immutable/Private/Immutable/ImmutablePassport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void UImmutablePassport::Initialize(const FImtblPassportResponseDelegate& Respon
}

#if PLATFORM_ANDROID | PLATFORM_IOS | PLATFORM_MAC | PLATFORM_WINDOWS
void UImmutablePassport::Connect(bool IsConnectImx, const FImtblPassportResponseDelegate& ResponseDelegate)
void UImmutablePassport::Connect(bool IsConnectImx, const FImtblPassportResponseDelegate& ResponseDelegate, EImmutableDirectLoginMethod DirectLoginMethod)
{
SetStateFlags(IPS_CONNECTING | IPS_PKCE);

Expand All @@ -108,7 +108,34 @@ void UImmutablePassport::Connect(bool IsConnectImx, const FImtblPassportResponse
}
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::OnGetAuthUrlResponse));

FImmutableGetPKCEAuthUrlRequest PKCERequest;
PKCERequest.isConnectImx = IsConnectImx;
PKCERequest.directLoginMethod = DirectLoginMethod;

// Custom export callback to handle all enums to use lowercase
FJsonObjectConverter::CustomExportCallback CustomCallback;
CustomCallback.BindLambda([](FProperty* Property, const void* Value) -> TSharedPtr<FJsonValue>
{
if (FEnumProperty* EnumProperty = CastField<FEnumProperty>(Property))
{
int64 EnumValue = EnumProperty->GetUnderlyingProperty()->GetSignedIntPropertyValue(Value);

if (UEnum* Enum = EnumProperty->GetEnum())
{
FString EnumNameString = Enum->GetNameStringByValue(EnumValue);
return MakeShareable(new FJsonValueString(EnumNameString.ToLower()));
}
}

// Return null to use default serialization for non-enum properties
return TSharedPtr<FJsonValue>();
});

FString PKCERequestJson;
FJsonObjectConverter::UStructToJsonObjectString(PKCERequest, PKCERequestJson, 0, 0, 0, &CustomCallback);

CallJS(ImmutablePassportAction::GetPKCEAuthUrl, PKCERequestJson, PKCEResponseDelegate, FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::OnGetAuthUrlResponse));
}
#endif

Expand Down Expand Up @@ -754,4 +781,4 @@ void UImmutablePassport::LaunchAndroidUrl(FString Url)
CallJniStaticVoidMethod(Env, jimmutableAndroidClass, jlaunchUrl, FJavaWrapper::GameActivityThis, jurl);
}
}
#endif
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,23 @@ class IMMUTABLE_API UImtblConnectionAsyncActions : public UImtblBlueprintAsyncAc
* Log into Passport
*
* @param WorldContextObject World context
* @param DirectLoginMethod Direct login method to use for authentication (defaults to None for standard login page)
*
* @return A reference to the object represented by this node
*/
UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject", BlueprintInternalUseOnly = "true"), Category = "Immutable")
static UImtblConnectionAsyncActions* Login(UObject* WorldContextObject);
static UImtblConnectionAsyncActions* Login(UObject* WorldContextObject, EImmutableDirectLoginMethod DirectLoginMethod = EImmutableDirectLoginMethod::None);

/**
* Log into Passport, initialise the gamer's wallet and instantiate the IMX provider.
*
* @param WorldContextObject World context
* @param DirectLoginMethod Direct login method to use for authentication (defaults to None for standard login page)
*
* @return A reference to the object represented by this node
*/
UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject", BlueprintInternalUseOnly = "true"), Category = "Immutable")
static UImtblConnectionAsyncActions* ConnectImx(UObject* WorldContextObject);
static UImtblConnectionAsyncActions* ConnectImx(UObject* WorldContextObject, EImmutableDirectLoginMethod DirectLoginMethod = EImmutableDirectLoginMethod::None);


virtual void Activate() override;
Expand All @@ -54,4 +56,5 @@ class IMMUTABLE_API UImtblConnectionAsyncActions : public UImtblBlueprintAsyncAc
bool bUseCachedSession = false;
bool bIsConnectImx = false;
bool bIsPKCE = false;
EImmutableDirectLoginMethod DirectLoginMethod = EImmutableDirectLoginMethod::None;
};
29 changes: 29 additions & 0 deletions Source/Immutable/Public/Immutable/ImmutableDataTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FImmutableDeepLinkDynamicMulticastDe
// This hardcoded value will be updated by a workflow during the release process.
#define ENGINE_SDK_VERSION TEXT("1.11.0")

/**
* Enum representing direct login methods for authentication providers
*/
UENUM(BlueprintType)
enum class EImmutableDirectLoginMethod : uint8
{
None,
Google,
Apple,
Facebook
};

USTRUCT()
struct FImmutableEngineVersionData
{
Expand Down Expand Up @@ -147,6 +159,23 @@ struct FImmutablePassportConnectData
FString state;
};

/**
* Structure to hold PKCE authentication URL request data
*/
USTRUCT()
struct IMMUTABLE_API FImmutableGetPKCEAuthUrlRequest
{
GENERATED_BODY()

/** Whether this is a ConnectImx operation (true) or just Login (false) */
UPROPERTY()
bool isConnectImx = false;

/** Direct login method to use for authentication */
UPROPERTY()
EImmutableDirectLoginMethod directLoginMethod = EImmutableDirectLoginMethod::None;
};

USTRUCT()
struct IMMUTABLE_API FImmutablePassportResult
{
Expand Down
3 changes: 2 additions & 1 deletion Source/Immutable/Public/Immutable/ImmutablePassport.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,9 @@ class IMMUTABLE_API UImmutablePassport : public UObject
* @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.
* @param DirectLoginMethod Direct login method to use for authentication (defaults to None for standard login page).
*/
void Connect(bool IsConnectImx, const FImtblPassportResponseDelegate& ResponseDelegate);
void Connect(bool IsConnectImx, const FImtblPassportResponseDelegate& ResponseDelegate, EImmutableDirectLoginMethod DirectLoginMethod = EImmutableDirectLoginMethod::None);
#endif

/**
Expand Down
Loading