diff --git a/Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet.Authentication/AWS.cs b/Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet.Authentication/AWS.cs index 45d52c3..9d23432 100644 --- a/Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet.Authentication/AWS.cs +++ b/Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet.Authentication/AWS.cs @@ -10,7 +10,7 @@ internal class AWS private const string cognitoAppClientId = "2e02ha2ce6du13ldk8pai4h3d0"; private static readonly string cognitoIdentityPoolId = $"{awsRegion}:2ad7ab1e-f48b-48a6-adfa-ac1090689c26"; private static readonly string cognitoUserPoolId = $"{awsRegion}_UFwLcZIpq"; - private static readonly string recoverySharePasswordLambdaFunctionName = "arn:aws:lambda:us-west-2:324457261097:function:recovery-share-password-GenerateRecoverySharePassw-bbE5ZbVAToil"; + private static readonly string recoverySharePasswordLambdaFunctionName = $"arn:aws:lambda:{awsRegion}:324457261097:function:recovery-share-password-GenerateRecoverySharePassw-bbE5ZbVAToil"; internal static async Task SignUpCognitoUserAsync(string emailAddress, string userName, Type thirdwebHttpClientType) { diff --git a/Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet.Authentication/Server.cs b/Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet.Authentication/Server.cs index 2d2b3ba..e892072 100644 --- a/Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet.Authentication/Server.cs +++ b/Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet.Authentication/Server.cs @@ -18,7 +18,7 @@ internal abstract class ServerBase internal abstract Task<(string authShare, string recoveryShare)> FetchAuthAndRecoverySharesAsync(string authToken); internal abstract Task FetchAuthShareAsync(string authToken); - internal abstract Task FetchHeadlessOauthLoginLinkAsync(string authProvider); + internal abstract Task FetchHeadlessOauthLoginLinkAsync(string authProvider, string platform); internal abstract Task CheckIsEmailKmsOtpValidAsync(string userName, string otp); internal abstract Task CheckIsEmailUserOtpValidAsync(string emailAddress, string otp); @@ -177,13 +177,13 @@ private async Task FetchCognitoIdTokenAsync(string authToken) } // embedded-wallet/headless-oauth-login-link - internal override async Task FetchHeadlessOauthLoginLinkAsync(string authProvider) + internal override async Task FetchHeadlessOauthLoginLinkAsync(string authProvider, string platform) { var uri = MakeUri( "/embedded-wallet/headless-oauth-login-link", new Dictionary { - { "platform", "unity" }, + { "platform", platform }, { "authProvider", authProvider }, { "baseUrl", "https://embedded-wallet.thirdweb.com" } } diff --git a/Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet/EmbeddedWallet.EmailOTP.cs b/Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet/EmbeddedWallet.EmailOTP.cs index aba2fd7..ecd6cfd 100644 --- a/Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet/EmbeddedWallet.EmailOTP.cs +++ b/Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet/EmbeddedWallet.EmailOTP.cs @@ -33,10 +33,10 @@ public async Task VerifyOtpAsync(string emailAddress, string otp, { if (localStorage.Session.IsKmsWallet) { - // if (!await server.CheckIsEmailKmsOtpValidAsync(emailAddress, otp)) - // { - // throw new VerificationException("Invalid OTP", true); - // } + if (!await server.CheckIsEmailKmsOtpValidAsync(emailAddress, otp)) + { + throw new VerificationException("Invalid OTP", true); + } Server.VerifyResult result = await server.VerifyKmsOtpAsync(emailAddress, otp, localStorage.Session.Id).ConfigureAwait(false); await localStorage.RemoveSessionAsync().ConfigureAwait(false); return await PostAuthSetup(result, recoveryCode, null, "EmailOTP").ConfigureAwait(false); diff --git a/Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet/EmbeddedWallet.OAuth.cs b/Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet/EmbeddedWallet.OAuth.cs index 1197e8e..e505c53 100644 --- a/Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet/EmbeddedWallet.OAuth.cs +++ b/Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet/EmbeddedWallet.OAuth.cs @@ -12,9 +12,9 @@ public async Task SignInWithOauthAsync(string authProvider, string return await PostAuthSetup(result, recoveryCode, null, authProvider).ConfigureAwait(false); } - public async Task FetchHeadlessOauthLoginLinkAsync(string authProvider) + public async Task FetchHeadlessOauthLoginLinkAsync(string authProvider, string platform) { - return await server.FetchHeadlessOauthLoginLinkAsync(authProvider).ConfigureAwait(false); + return await server.FetchHeadlessOauthLoginLinkAsync(authProvider, platform).ConfigureAwait(false); } public async Task IsRecoveryCodeNeededAsync(string authResultStr) diff --git a/Thirdweb/Thirdweb.Wallets/InAppWallet/InAppWallet.cs b/Thirdweb/Thirdweb.Wallets/InAppWallet/InAppWallet.cs index 0da9e59..cf8fd51 100644 --- a/Thirdweb/Thirdweb.Wallets/InAppWallet/InAppWallet.cs +++ b/Thirdweb/Thirdweb.Wallets/InAppWallet/InAppWallet.cs @@ -90,10 +90,9 @@ public virtual async Task LoginWithOauth( throw new ArgumentNullException(nameof(mobileRedirectScheme), "Mobile redirect scheme cannot be null or empty on this platform."); } - // TODO: Use this for login link when it's ready in backend - var platform = "unity"; + var platform = _client.HttpClient?.Headers["x-sdk-platform"] ?? "dotnet"; var redirectUrl = isMobile ? mobileRedirectScheme : "http://localhost:8789/"; - var loginUrl = await _embeddedWallet.FetchHeadlessOauthLoginLinkAsync(_authProvider); + var loginUrl = await _embeddedWallet.FetchHeadlessOauthLoginLinkAsync(_authProvider, platform); loginUrl = $"{loginUrl}?platform={platform}&redirectUrl={redirectUrl}&developerClientId={_client.ClientId}&authOption={_authProvider}"; browser ??= new InAppWalletBrowser();