diff --git a/Plugins/Web3AuthSDK/Source/Web3AuthSDK/Private/Web3Auth.cpp b/Plugins/Web3AuthSDK/Source/Web3AuthSDK/Private/Web3Auth.cpp index 65b183c..c990d99 100644 --- a/Plugins/Web3AuthSDK/Source/Web3AuthSDK/Private/Web3Auth.cpp +++ b/Plugins/Web3AuthSDK/Source/Web3AuthSDK/Private/Web3Auth.cpp @@ -51,7 +51,7 @@ void UWeb3Auth::setOptions(FWeb3AuthOptions options) { authorizeSession(); } -void UWeb3Auth::request(FString path, FLoginParams* loginParams = NULL, TSharedPtr extraParams = NULL) { +void UWeb3Auth::request(FString path, FLoginParams* loginParams = nullptr, TSharedPtr extraParams = nullptr) { TSharedPtr paramMap = MakeShareable(new FJsonObject); @@ -81,7 +81,7 @@ void UWeb3Auth::request(FString path, FLoginParams* loginParams = NULL, TSharedP FMfaSettings defaultMFA; - if (!(web3AuthOptions.mfaSettings == defaultMFA)) + if (web3AuthOptions.mfaSettings != defaultMFA) { FString mfaSettingsJson; FJsonObjectConverter::UStructToJsonObjectString(web3AuthOptions.mfaSettings, mfaSettingsJson); @@ -157,11 +157,11 @@ void UWeb3Auth::request(FString path, FLoginParams* loginParams = NULL, TSharedP params->SetStringField("curve", "ed25519"); } - if (extraParams != NULL) { + if (extraParams != nullptr) { params = extraParams; } - if (loginParams != NULL) { + if (loginParams != nullptr) { for (auto o : loginParams->getJsonObject().Values) { params->SetField(o.Key, o.Value); } @@ -247,7 +247,7 @@ void UWeb3Auth::launchWalletServices(FLoginParams loginParams, FChainConfig chai FMfaSettings defaultMFA; - if (!(web3AuthOptions.mfaSettings == defaultMFA)) { + if (web3AuthOptions.mfaSettings != defaultMFA) { FString mfaSettingsJson; FJsonObjectConverter::UStructToJsonObjectString(web3AuthOptions.mfaSettings, mfaSettingsJson); @@ -403,12 +403,12 @@ void UWeb3Auth::setResultUrl(FString hash) { int32 braceIndex = decodedString.Find(TEXT("}")); FString substringBeforeBrace = decodedString.Left(braceIndex + 1); //UE_LOG(LogTemp, Warning, TEXT("substringBeforeBrace: %s"), *substringBeforeBrace); - - FSessionResponse response; + TSharedPtr jsonObject; TSharedRef> reader = TJsonReaderFactory<>::Create(substringBeforeBrace); if (FJsonSerializer::Deserialize(reader, jsonObject) && jsonObject.IsValid()) { + FSessionResponse response; jsonObject->TryGetStringField(TEXT("sessionId"), response.sessionId); //UE_LOG(LogTemp, Warning, TEXT("Session-ID: %s"), *response.sessionId); keyStoreUtils->Assign(*response.sessionId); @@ -439,11 +439,12 @@ FString UWeb3Auth::startLocalWebServer() { } if (httpRouter.IsValid()) { + auto x = httpRouter->BindRoute(FHttpPath(TEXT("/auth")), EHttpServerRequestVerbs::VERB_GET, - [this](const FHttpServerRequest& Request, const FHttpResultCallback& OnComplete) { return requestAuthCallback(Request, OnComplete); }); + FHttpRequestHandler::CreateLambda([this](const FHttpServerRequest& Request, const FHttpResultCallback& OnComplete) { return requestAuthCallback(Request, OnComplete); })); auto y = httpRouter->BindRoute(FHttpPath(TEXT("/complete")), EHttpServerRequestVerbs::VERB_GET, - [this](const FHttpServerRequest& Request, const FHttpResultCallback& OnComplete) { return requestCompleteCallback(Request, OnComplete); }); + FHttpRequestHandler::CreateLambda([this](const FHttpServerRequest& Request, const FHttpResultCallback& OnComplete) { return requestCompleteCallback(Request, OnComplete); })); httpRoutes.Add(TPairInitializer, FHttpRouteHandle>(httpRouter, x)); httpRoutes.Add(TPairInitializer, FHttpRouteHandle>(httpRouter, y)); @@ -502,7 +503,7 @@ bool UWeb3Auth::requestCompleteCallback(const FHttpServerRequest& Request, const if (window.location.hash.trim() == "") { document.querySelector("#error").style.display="flex"; } else { - fetch(`http://${window.location.host}/auth/?code=${window.location.hash.slice(1,window.location.hash.length)}`).then(function(response) { + fetch(`https://${window.location.host}/auth/?code=${window.location.hash.slice(1,window.location.hash.length)}`).then(function(response) { console.log(response); document.querySelector("#success").style.display="flex"; }).catch(function(error) { @@ -572,7 +573,7 @@ void UWeb3Auth::authorizeSession() { if (!this->sessionId.IsEmpty()) { FString pubKey = crypto->generatePublicKey(this->sessionId); FString session = this->sessionId; - web3AuthApi->AuthorizeSession(pubKey, [session, this](FStoreApiResponse response) + web3AuthApi->AuthorizeSession(pubKey, [session, this](const FStoreApiResponse& response) { //UE_LOG(LogTemp, Log, TEXT("Response: %s"), *response.message); @@ -602,9 +603,9 @@ void UWeb3Auth::authorizeSession() { if (web3AuthResponse.error != "") { return; } - - this->loginEvent.ExecuteIfBound(web3AuthResponse); - this->mfaEvent.ExecuteIfBound(true); + + (void) this->loginEvent.ExecuteIfBound(web3AuthResponse); + (void) this->mfaEvent.ExecuteIfBound(true); } }); @@ -618,7 +619,7 @@ void UWeb3Auth::sessionTimeout() { if (!this->sessionId.IsEmpty()) { FString pubKey = crypto->generatePublicKey(this->sessionId); - web3AuthApi->AuthorizeSession(pubKey, [pubKey, this](FStoreApiResponse response) + web3AuthApi->AuthorizeSession(pubKey, [pubKey, this](const FStoreApiResponse& response) { FShareMetaData shareMetaData; @@ -645,10 +646,10 @@ void UWeb3Auth::sessionTimeout() { request.signature = sig; request.timeout = 1; - web3AuthApi->Logout(request, [this](FString response) + web3AuthApi->Logout(request, [this](const FString& response) { UE_LOG(LogTemp, Log, TEXT("Response: %s"), *response); - this->logoutEvent.ExecuteIfBound(); + (void) this->logoutEvent.ExecuteIfBound(); this->sessionId = FString(); keyStoreUtils->Clear(); }); @@ -694,7 +695,7 @@ void UWeb3Auth::createSession(const FString& jsonData, int32 sessionTime, bool i request.signature = sig; request.timeout = FMath::Min(sessionTime, 7 * 86400); - web3AuthApi->CreateSession(request, [this, newSessionKey, isWalletService](FString response) + web3AuthApi->CreateSession(request, [this, newSessionKey, isWalletService](const FString& response) { UE_LOG(LogTemp, Log, TEXT("Response: %s"), *response); if(isWalletService) { @@ -705,7 +706,7 @@ void UWeb3Auth::createSession(const FString& jsonData, int32 sessionTime, bool i }); } -void UWeb3Auth::handleCreateSessionResponse(FString path, FString newSessionKey, bool isWalletService) { +void UWeb3Auth::handleCreateSessionResponse(const FString& path, const FString& newSessionKey, bool isWalletService) { TSharedPtr loginIdObject = MakeShareable(new FJsonObject); loginIdObject->SetStringField(TEXT("loginId"), newSessionKey); @@ -742,7 +743,7 @@ void UWeb3Auth::handleCreateSessionResponse(FString path, FString newSessionKey, thiz_instance = this; [[WebAuthenticate Singleton] launchUrl:TCHAR_TO_ANSI(*url)]; #else - FPlatformProcess::LaunchURL(*url, NULL, NULL); + FPlatformProcess::LaunchURL(*url, nullptr, nullptr); #endif } diff --git a/Plugins/Web3AuthSDK/Source/Web3AuthSDK/Public/Web3Auth.h b/Plugins/Web3AuthSDK/Source/Web3AuthSDK/Public/Web3Auth.h index 100ffa8..acea12a 100644 --- a/Plugins/Web3AuthSDK/Source/Web3AuthSDK/Public/Web3Auth.h +++ b/Plugins/Web3AuthSDK/Source/Web3AuthSDK/Public/Web3Auth.h @@ -849,10 +849,10 @@ class WEB3AUTHSDK_API UWeb3Auth : public UGameInstanceSubsystem FString startLocalWebServer(); bool requestAuthCallback(const FHttpServerRequest& Request, const FHttpResultCallback& OnComplete); - bool requestCompleteCallback(const FHttpServerRequest& Request, const FHttpResultCallback& OnComplete); + static bool requestCompleteCallback(const FHttpServerRequest& Request, const FHttpResultCallback& OnComplete); void authorizeSession(); void sessionTimeout(); void createSession(const FString& jsonData, int32 sessionTime, bool isWalletService); - void handleCreateSessionResponse(FString path, FString newSessionKey, bool isWalletService); + void handleCreateSessionResponse(const FString& path, const FString& newSessionKey, bool isWalletService); }; diff --git a/Source/Web3AuthUnrealSDK.Target.cs b/Source/Web3AuthUnrealSDK.Target.cs index 2e33666..a8e47db 100644 --- a/Source/Web3AuthUnrealSDK.Target.cs +++ b/Source/Web3AuthUnrealSDK.Target.cs @@ -8,7 +8,9 @@ public class Web3AuthUnrealSDKTarget : TargetRules public Web3AuthUnrealSDKTarget( TargetInfo Target) : base(Target) { Type = TargetType.Game; - DefaultBuildSettings = BuildSettingsVersion.V2; + DefaultBuildSettings = BuildSettingsVersion.Latest; + IncludeOrderVersion = EngineIncludeOrderVersion.Latest; + bOverrideBuildEnvironment = true; ExtraModuleNames.AddRange( new string[] { "Web3AuthUnrealSDK" } ); } } diff --git a/Source/Web3AuthUnrealSDKEditor.Target.cs b/Source/Web3AuthUnrealSDKEditor.Target.cs index fe63431..cc1ecf9 100644 --- a/Source/Web3AuthUnrealSDKEditor.Target.cs +++ b/Source/Web3AuthUnrealSDKEditor.Target.cs @@ -8,7 +8,9 @@ public class Web3AuthUnrealSDKEditorTarget : TargetRules public Web3AuthUnrealSDKEditorTarget( TargetInfo Target) : base(Target) { Type = TargetType.Editor; - DefaultBuildSettings = BuildSettingsVersion.V2; + DefaultBuildSettings = BuildSettingsVersion.Latest; + IncludeOrderVersion = EngineIncludeOrderVersion.Latest; + bOverrideBuildEnvironment = true; ExtraModuleNames.AddRange( new string[] { "Web3AuthUnrealSDK" } ); } }