diff --git a/Plugins/SequencePlugin/Content/Core/Demonstration/BP_CustomSpectatorPawn.uasset b/Plugins/SequencePlugin/Content/Core/Demonstration/BP_CustomSpectatorPawn.uasset index b6e32fae0..2778938db 100644 --- a/Plugins/SequencePlugin/Content/Core/Demonstration/BP_CustomSpectatorPawn.uasset +++ b/Plugins/SequencePlugin/Content/Core/Demonstration/BP_CustomSpectatorPawn.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:110418f281a20ad3478a02bc6db836c6fae19e9b841fb1347784c90d51fe057d -size 97419 +oid sha256:9f975791f8c5205a382591d555a19dde738b0debdbd759e6ad864c3d7bd844c9 +size 101281 diff --git a/Plugins/SequencePlugin/Content/Core/Pawn_Components/AC_SequencePawn_Component.uasset b/Plugins/SequencePlugin/Content/Core/Pawn_Components/AC_SequencePawn_Component.uasset index 35f368fef..3f8e2754d 100644 --- a/Plugins/SequencePlugin/Content/Core/Pawn_Components/AC_SequencePawn_Component.uasset +++ b/Plugins/SequencePlugin/Content/Core/Pawn_Components/AC_SequencePawn_Component.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1db36144f755e12b1448729f9119bae88718d39e7286e0212eb8dbb7bac5d9f4 -size 116508 +oid sha256:b38d3b49ddfbfd654a8177575e5d08a4603ff335d3f4919f7dc0efccaad8b6d2 +size 149130 diff --git a/Plugins/SequencePlugin/Content/Core/Sqn_Mngrs/BP_SequenceManager.uasset b/Plugins/SequencePlugin/Content/Core/Sqn_Mngrs/BP_SequenceManager.uasset index c829d23dd..b759e968f 100644 --- a/Plugins/SequencePlugin/Content/Core/Sqn_Mngrs/BP_SequenceManager.uasset +++ b/Plugins/SequencePlugin/Content/Core/Sqn_Mngrs/BP_SequenceManager.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:74c42ccedeb3275e644534faa4281e4bda6839c701419cccd239b684b20eb404 -size 2102339 +oid sha256:30aca22f728d164d9099043a156bf437edef9d4353a2f6466510f10bccff62fa +size 2174970 diff --git a/Plugins/SequencePlugin/Content/Core/Sqn_Mngrs/BP_SqncBkndMngr.uasset b/Plugins/SequencePlugin/Content/Core/Sqn_Mngrs/BP_SqncBkndMngr.uasset index 1bb2e56a4..81b6b74f0 100644 --- a/Plugins/SequencePlugin/Content/Core/Sqn_Mngrs/BP_SqncBkndMngr.uasset +++ b/Plugins/SequencePlugin/Content/Core/Sqn_Mngrs/BP_SqncBkndMngr.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:407bdb2e166f17ecad39b70b642fd6e9531e6c4af5ab86830868ef72016d1988 -size 93772 +oid sha256:0493d5f5e74bdf86ca2d46a47a070a4acfddc52d46a6302940b83786247ba085 +size 107524 diff --git a/Plugins/SequencePlugin/README.md b/Plugins/SequencePlugin/README.md index a2744d185..6eb189809 100644 --- a/Plugins/SequencePlugin/README.md +++ b/Plugins/SequencePlugin/README.md @@ -1,6 +1,11 @@ Sequence Unreal SDK =================== +This plugin requires the modern xcode setting to be enabled to build on MacOS. +See [the following link](https://dev.epicgames.com/documentation/en-us/unreal-engine/using-modern-xcode-in-unreal-engine-5.3-and-newer) for more details. + +=================== + This SDK allows easy integration of Sequence Embedded Wallet from any Unreal Framework project. ## Manually Upgrading from previous versions @@ -754,7 +759,6 @@ Refer to [these docs](https://developers.google.com/identity/one-tap/android/get #### iOS For iOS apps you also need to setup provisioning, [following these docs](https://dev.epicgames.com/documentation/en-us/unreal-engine/setting-up-ios-tvos-and-ipados-provisioning-profiles-and-signing-certificates-for-unreal-engine-projects?application_version=5.3) -New to 5.3 the ability to use Modernized XCode has been added. However we've experienced many issues with this setting enabled and recommend turning it off. ### Android When setting up your project to build for Android you'll need to update the following settings: diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Private/Authenticator.cpp b/Plugins/SequencePlugin/Source/SequencePlugin/Private/Authenticator.cpp index 4541f4592..f129123a1 100644 --- a/Plugins/SequencePlugin/Source/SequencePlugin/Private/Authenticator.cpp +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Private/Authenticator.cpp @@ -16,6 +16,7 @@ #include "Bitcoin-Cryptography-Library/cpp/Keccak256.hpp" #include "Interfaces/IHttpResponse.h" #include "Native/NativeOAuth.h" +#include "NativeEncryptors/WindowsEncryptor.h" #include "Sequence/SequenceAPI.h" UAuthenticator::UAuthenticator() @@ -45,7 +46,7 @@ UAuthenticator::UAuthenticator() } else if constexpr (PLATFORM_WINDOWS) { - + this->Encryptor = NewObject(); } else if constexpr (PLATFORM_IOS) { @@ -53,16 +54,18 @@ UAuthenticator::UAuthenticator() } } -UAuthenticator * UAuthenticator::Make(UGenericNativeEncryptor * EncryptorIn) -{ - UAuthenticator * Authenticator = NewObject(); - Authenticator->Init(EncryptorIn); - return Authenticator; -} - -void UAuthenticator::Init(UGenericNativeEncryptor * EncryptorIn) +void UAuthenticator::SetCustomEncryptor(UGenericNativeEncryptor * EncryptorIn) { this->Encryptor = EncryptorIn; + if (this->Encryptor) + { + const FString EncryptorName = this->Encryptor->GetClass()->GetName(); + UE_LOG(LogTemp,Display,TEXT("Setting custom encryptor to: %s"),*EncryptorName); + } + else + { + UE_LOG(LogTemp,Warning,TEXT("Received null instead of a pointer to an Encryptor Object using fallback encryptor")); + } } void UAuthenticator::ClearStoredCredentials() const diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Private/NativeEncryptors/AndroidEncryptor.cpp b/Plugins/SequencePlugin/Source/SequencePlugin/Private/NativeEncryptors/AndroidEncryptor.cpp index c499c0132..f4ac475a1 100644 --- a/Plugins/SequencePlugin/Source/SequencePlugin/Private/NativeEncryptors/AndroidEncryptor.cpp +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Private/NativeEncryptors/AndroidEncryptor.cpp @@ -30,7 +30,7 @@ FString UAndroidEncryptor::Encrypt(const FString& StringIn) jenv->DeleteLocalRef(gameActivityClass); } #endif - UE_LOG(LogTemp,Display,TEXT("Encrypted Result: %s"),*Result); + //UE_LOG(LogTemp,Display,TEXT("Encrypted Result: %s"),*Result); return Result; } @@ -56,6 +56,6 @@ FString UAndroidEncryptor::Decrypt(const FString& StringIn) jenv->DeleteLocalRef(gameActivityClass); } #endif - UE_LOG(LogTemp,Display,TEXT("Decrypted Result: %s"),*Result); + //UE_LOG(LogTemp,Display,TEXT("Decrypted Result: %s"),*Result); return Result; } diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Private/NativeEncryptors/WindowsEncryptor.cpp b/Plugins/SequencePlugin/Source/SequencePlugin/Private/NativeEncryptors/WindowsEncryptor.cpp new file mode 100644 index 000000000..0131b5aec --- /dev/null +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Private/NativeEncryptors/WindowsEncryptor.cpp @@ -0,0 +1,120 @@ +//Copyright 2024 Horizon Blockchain Games Inc. All rights reserved. + +#include "NativeEncryptors/WindowsEncryptor.h" +#include "Misc/Base64.h" +#include "Internationalization/Regex.h" + +#if PLATFORM_WINDOWS +#include "Windows/WindowsHWrapper.h" +#include "dpapi.h" +#endif + +FString UWindowsEncryptor::Encrypt(const FString& StringIn) +{ + FString Result = ""; + UE_LOG(LogTemp,Display,TEXT("Preparing to encrypt on windows: %s"),*StringIn); +#if PLATFORM_WINDOWS + DATA_BLOB DataIn; + DATA_BLOB DataOut; + const FString ProcString = FBase64::Encode(StringIn); + + //UE_LOG(LogTemp,Display,TEXT("Decrypted PreResult: %s"),*ProcString); + //UE_LOG(LogTemp,Display,TEXT("PreResult Length: %d"),ProcString.Len()); + + const int32 InSize = ProcString.Len(); + uint8 * CharsIn = new uint8[InSize]; + StringToBytes(ProcString,CharsIn,InSize); + BYTE *pbDataInput = CharsIn; + const DWORD cbDataInput = InSize; + UE_LOG(LogTemp,Display,TEXT("InByteCount: %d"),cbDataInput); + + DataIn.pbData = pbDataInput; + DataIn.cbData = cbDataInput; + if (CryptProtectData( + &DataIn, + NULL, + NULL, + NULL, + NULL, + 0, + &DataOut)) + { + BytesToHex(DataOut.pbData,DataOut.cbData,Result); + LocalFree(DataOut.pbData); + } + else + { + UE_LOG(LogTemp,Display,TEXT("Encryption Failed on windows")); + } + delete[] CharsIn; +#endif + //UE_LOG(LogTemp,Display,TEXT("Encrypted Result: %s"),*Result); + return Result; +} + +FString UWindowsEncryptor::Decrypt(const FString& StringIn) +{ + FString Result = ""; + UE_LOG(LogTemp,Display,TEXT("Preparing to decrypt on windows: %s"),*StringIn); +#if PLATFORM_WINDOWS + DATA_BLOB DataIn; + DATA_BLOB DataOut; + + const int32 InSize = StringIn.Len() / 2; + uint8 * CharsIn = new uint8[InSize]; + + const FRegexPattern HexPattern(TEXT("^[a-fA-F0-9]+$")); + FRegexMatcher HexChecker(HexPattern,StringIn); + + if (HexChecker.FindNext()) + { + HexToBytes(StringIn,CharsIn); + } + else + { + delete[] CharsIn; + UE_LOG(LogTemp,Error,TEXT("Provided String is InValid and cannot be decoded!")); + return ""; + } + + BYTE *pbDataInput = CharsIn; + const DWORD cbDataInput = InSize; + DataIn.pbData = pbDataInput; + DataIn.cbData = cbDataInput; + LPWSTR pDescrOut = NULL; + if (CryptUnprotectData( + &DataIn, + &pDescrOut, + NULL, + NULL, + NULL, + 0, + &DataOut)) + { + const FString PreResult = BytesToString(DataOut.pbData,DataOut.cbData); + + //UE_LOG(LogTemp,Display,TEXT("Decrypted PreResult: %s"),*PreResult); + //UE_LOG(LogTemp,Display,TEXT("PreResult Length: %d"),PreResult.Len()); + + if (FBase64::Decode(PreResult,Result)) + { + UE_LOG(LogTemp,Display,TEXT("Successful B64 Decode")); + } + else + { + UE_LOG(LogTemp,Error,TEXT("UnSuccessful B64 Decode")); + } + + LocalFree(DataOut.pbData); + LocalFree(pDescrOut); + } + else + { + const int32 ErrorCode = GetLastError(); + UE_LOG(LogTemp,Display,TEXT("Decryption Failed on windows, Error code: %d"),ErrorCode); + } + delete[] CharsIn; +#endif + //UE_LOG(LogTemp,Display,TEXT("Decrypted Result: %s"),*Result); + return Result; +} diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Private/SequenceBackendManager.cpp b/Plugins/SequencePlugin/Source/SequencePlugin/Private/SequenceBackendManager.cpp index 7cd536a3f..90470623c 100644 --- a/Plugins/SequencePlugin/Source/SequencePlugin/Private/SequenceBackendManager.cpp +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Private/SequenceBackendManager.cpp @@ -62,6 +62,14 @@ void ASequenceBackendManager::BeginPlay() //SYNC FUNCTIONAL CALLS// [THESE ARE BLOCKING CALLS AND WILL RETURN DATA IMMEDIATELY] +void ASequenceBackendManager::SetupCustomEncryptor(UGenericNativeEncryptor * EncryptorIn) +{ + if (this->Authenticator) + { + this->Authenticator->SetCustomEncryptor(EncryptorIn); + } +} + /* Used to copy data to the systems clipboard! */ diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Public/Authenticator.h b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Authenticator.h index 88e53c42d..ba11278fd 100644 --- a/Plugins/SequencePlugin/Source/SequencePlugin/Public/Authenticator.h +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Authenticator.h @@ -381,7 +381,7 @@ class SEQUENCEPLUGIN_API UAuthenticator : public UObject private: UAuthenticator(); public: - static UAuthenticator * Make(UGenericNativeEncryptor * EncryptorIn); + void SetCustomEncryptor(UGenericNativeEncryptor * EncryptorIn); FString GetSigninURL(const ESocialSigninType& Type); @@ -401,8 +401,6 @@ class SEQUENCEPLUGIN_API UAuthenticator : public UObject void ClearStoredCredentials() const; private: - void Init(UGenericNativeEncryptor * EncryptorIn); - bool CanHandleEmailLogin(); bool GetStoredCredentials(FCredentials_BE * Credentials) const; diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Public/NativeEncryptors/AndroidEncryptor.h b/Plugins/SequencePlugin/Source/SequencePlugin/Public/NativeEncryptors/AndroidEncryptor.h index 01e8eed7c..5c2d2b57e 100644 --- a/Plugins/SequencePlugin/Source/SequencePlugin/Public/NativeEncryptors/AndroidEncryptor.h +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Public/NativeEncryptors/AndroidEncryptor.h @@ -9,7 +9,7 @@ /** * */ -UCLASS() +UCLASS(Blueprintable) class SEQUENCEPLUGIN_API UAndroidEncryptor : public UGenericNativeEncryptor { GENERATED_BODY() diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Public/NativeEncryptors/GenericNativeEncryptor.h b/Plugins/SequencePlugin/Source/SequencePlugin/Public/NativeEncryptors/GenericNativeEncryptor.h index b862bee5c..1bd3de57c 100644 --- a/Plugins/SequencePlugin/Source/SequencePlugin/Public/NativeEncryptors/GenericNativeEncryptor.h +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Public/NativeEncryptors/GenericNativeEncryptor.h @@ -9,7 +9,7 @@ /** * */ -UCLASS() +UCLASS(Blueprintable) class SEQUENCEPLUGIN_API UGenericNativeEncryptor : public UObject { GENERATED_BODY() diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Public/NativeEncryptors/WindowsEncryptor.h b/Plugins/SequencePlugin/Source/SequencePlugin/Public/NativeEncryptors/WindowsEncryptor.h new file mode 100644 index 000000000..4c4e3aab5 --- /dev/null +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Public/NativeEncryptors/WindowsEncryptor.h @@ -0,0 +1,21 @@ +//Copyright 2024 Horizon Blockchain Games Inc. All rights reserved. + +#pragma once + +#include "CoreMinimal.h" +#include "NativeEncryptors/GenericNativeEncryptor.h" +#include "WindowsEncryptor.generated.h" + +/** + * + */ +UCLASS(Blueprintable) +class SEQUENCEPLUGIN_API UWindowsEncryptor : public UGenericNativeEncryptor +{ + GENERATED_BODY() + +public: + virtual FString Encrypt(const FString& StringIn) override; + + virtual FString Decrypt(const FString& StringIn) override; +}; diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Public/SequenceBackendManager.h b/Plugins/SequencePlugin/Source/SequencePlugin/Public/SequenceBackendManager.h index 0ff9ff781..3502442ae 100644 --- a/Plugins/SequencePlugin/Source/SequencePlugin/Public/SequenceBackendManager.h +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Public/SequenceBackendManager.h @@ -71,6 +71,9 @@ class SEQUENCEPLUGIN_API ASequenceBackendManager : public AActor public: //SYNC FUNCTIONAL CALLS// [THESE ARE BLOCKING CALLS AND WILL RETURN DATA IMMEDIATELY] + + UFUNCTION(BlueprintCallable, CATEGORY="FUNCTION") + void SetupCustomEncryptor(UGenericNativeEncryptor * EncryptorIn); /* * Used to send data to clipboard for ease of use! diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/SequencePlugin.Build.cs b/Plugins/SequencePlugin/Source/SequencePlugin/SequencePlugin.Build.cs index 984ca78fc..99d879790 100644 --- a/Plugins/SequencePlugin/Source/SequencePlugin/SequencePlugin.Build.cs +++ b/Plugins/SequencePlugin/Source/SequencePlugin/SequencePlugin.Build.cs @@ -68,7 +68,16 @@ public SequencePlugin(ReadOnlyTargetRules Target) : base(Target) // ... add any modules that your module loads dynamically here ... } ); - + + if (Target.Platform == UnrealTargetPlatform.Win64) + { + PublicSystemLibraries.AddRange( + new string[] + { + "Crypt32.lib" + } + ); + } //Add IOS Specific Dependencies if (Target.Platform == UnrealTargetPlatform.IOS) diff --git a/README.md b/README.md index a2744d185..6eb189809 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,11 @@ Sequence Unreal SDK =================== +This plugin requires the modern xcode setting to be enabled to build on MacOS. +See [the following link](https://dev.epicgames.com/documentation/en-us/unreal-engine/using-modern-xcode-in-unreal-engine-5.3-and-newer) for more details. + +=================== + This SDK allows easy integration of Sequence Embedded Wallet from any Unreal Framework project. ## Manually Upgrading from previous versions @@ -754,7 +759,6 @@ Refer to [these docs](https://developers.google.com/identity/one-tap/android/get #### iOS For iOS apps you also need to setup provisioning, [following these docs](https://dev.epicgames.com/documentation/en-us/unreal-engine/setting-up-ios-tvos-and-ipados-provisioning-profiles-and-signing-certificates-for-unreal-engine-projects?application_version=5.3) -New to 5.3 the ability to use Modernized XCode has been added. However we've experienced many issues with this setting enabled and recommend turning it off. ### Android When setting up your project to build for Android you'll need to update the following settings: