diff --git a/Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet.Encryption/EmbeddedWallet.Cryptography.cs b/Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet.Encryption/EmbeddedWallet.Cryptography.cs index e5d0787..005baa3 100644 --- a/Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet.Encryption/EmbeddedWallet.Cryptography.cs +++ b/Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet.Encryption/EmbeddedWallet.Cryptography.cs @@ -27,7 +27,7 @@ private string DecryptShare(string encryptedShare, string password) } else { - iterationCount = DEPRECATED_ITERATION_COUNT; + iterationCount = CURRENT_ITERATION_COUNT; } byte[] key = GetEncryptionKey(password, salt, iterationCount); diff --git a/Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet.Storage/LocalStorage.cs b/Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet.Storage/LocalStorage.cs index 2d60736..191e4b5 100644 --- a/Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet.Storage/LocalStorage.cs +++ b/Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet.Storage/LocalStorage.cs @@ -27,13 +27,13 @@ internal partial class LocalStorage : LocalStorageBase private readonly Storage storage; private readonly string filePath; - internal LocalStorage(string clientId) + internal LocalStorage(string clientId, string storageDirectoryPath = null) { string directory; #if UNITY_5_3_OR_NEWER directory = Application.persistentDataPath; #else - directory = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); + directory = storageDirectoryPath ?? Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); // Console.WriteLine($"Embedded Wallet Storage: Using '{directory}'"); #endif directory = Path.Combine(directory, "EWS"); diff --git a/Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet/EmbeddedWallet.cs b/Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet/EmbeddedWallet.cs index e14ff66..3c6e290 100644 --- a/Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet/EmbeddedWallet.cs +++ b/Thirdweb/Thirdweb.Wallets/InAppWallet/EmbeddedWallet/EmbeddedWallet.cs @@ -11,13 +11,12 @@ internal partial class EmbeddedWallet private const int KEY_SIZE = 256 / 8; private const int TAG_SIZE = 16; private const int CURRENT_ITERATION_COUNT = 650_000; - private const int DEPRECATED_ITERATION_COUNT = 5_000_000; private const string WALLET_PRIVATE_KEY_PREFIX = "thirdweb_"; private const string ENCRYPTION_SEPARATOR = ":"; - public EmbeddedWallet(ThirdwebClient client) + public EmbeddedWallet(ThirdwebClient client, string storageDirectoryPath = null) { - localStorage = new LocalStorage(client.ClientId); + localStorage = new LocalStorage(client.ClientId, storageDirectoryPath); server = new Server(client.ClientId, client.BundleId, "dotnet", Constants.VERSION, client.SecretKey); ivGenerator = new IvGenerator(); } diff --git a/Thirdweb/Thirdweb.Wallets/InAppWallet/InAppWallet.cs b/Thirdweb/Thirdweb.Wallets/InAppWallet/InAppWallet.cs index 7a430cf..b5129de 100644 --- a/Thirdweb/Thirdweb.Wallets/InAppWallet/InAppWallet.cs +++ b/Thirdweb/Thirdweb.Wallets/InAppWallet/InAppWallet.cs @@ -30,7 +30,13 @@ internal InAppWallet(ThirdwebClient client, string email, string phoneNumber, st _authProvider = authProvider; } - public static async Task Create(ThirdwebClient client, string email = null, string phoneNumber = null, AuthProvider authprovider = AuthProvider.Default) + public static async Task Create( + ThirdwebClient client, + string email = null, + string phoneNumber = null, + AuthProvider authprovider = AuthProvider.Default, + string storageDirectoryPath = null + ) { if (string.IsNullOrEmpty(email) && string.IsNullOrEmpty(phoneNumber) && authprovider == AuthProvider.Default) { @@ -46,7 +52,7 @@ public static async Task Create(ThirdwebClient client, string email _ => throw new ArgumentException("Invalid AuthProvider"), }; - var embeddedWallet = new EmbeddedWallet(client); + var embeddedWallet = new EmbeddedWallet(client, storageDirectoryPath); EthECKey ecKey; try {