From 325625acacac51a98be36043060401adec37232f Mon Sep 17 00:00:00 2001 From: Firekeeper <0xFirekeeper@gmail.com> Date: Fri, 14 Feb 2025 02:06:12 +0700 Subject: [PATCH] Allow login with tw auth token (#129) --- .../InAppWallet/EcosystemWallet/EcosystemWallet.cs | 8 +++++++- Thirdweb/Thirdweb.Wallets/InAppWallet/InAppWallet.cs | 6 ++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Thirdweb/Thirdweb.Wallets/InAppWallet/EcosystemWallet/EcosystemWallet.cs b/Thirdweb/Thirdweb.Wallets/InAppWallet/EcosystemWallet/EcosystemWallet.cs index b990df9..256c74e 100644 --- a/Thirdweb/Thirdweb.Wallets/InAppWallet/EcosystemWallet/EcosystemWallet.cs +++ b/Thirdweb/Thirdweb.Wallets/InAppWallet/EcosystemWallet/EcosystemWallet.cs @@ -80,6 +80,7 @@ string walletSecret /// The SIWE signer wallet for SIWE authentication. /// The encryption key that is no longer required but was used in the past. Only pass this if you had used custom auth before this was deprecated. /// The wallet secret for Backend authentication. + /// The auth token to use for the session. This will automatically connect using a raw thirdweb auth token. /// A task that represents the asynchronous operation. The task result contains the created in-app wallet. /// Thrown when required parameters are not provided. public static async Task Create( @@ -92,7 +93,8 @@ public static async Task Create( string storageDirectoryPath = null, IThirdwebWallet siweSigner = null, string legacyEncryptionKey = null, - string walletSecret = null + string walletSecret = null, + string twAuthTokenOverride = null ) { if (client == null) @@ -154,6 +156,10 @@ public static async Task Create( storageDirectoryPath ??= Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Thirdweb", "EcosystemWallet"); var embeddedWallet = new EmbeddedWallet(client, storageDirectoryPath, ecosystemId, ecosystemPartnerId); + if (!string.IsNullOrWhiteSpace(twAuthTokenOverride)) + { + CreateEnclaveSession(embeddedWallet, twAuthTokenOverride, email, phoneNumber, authproviderStr, null); + } try { diff --git a/Thirdweb/Thirdweb.Wallets/InAppWallet/InAppWallet.cs b/Thirdweb/Thirdweb.Wallets/InAppWallet/InAppWallet.cs index b54d0dc..5cf9034 100644 --- a/Thirdweb/Thirdweb.Wallets/InAppWallet/InAppWallet.cs +++ b/Thirdweb/Thirdweb.Wallets/InAppWallet/InAppWallet.cs @@ -37,6 +37,7 @@ string walletSecret /// The SIWE signer wallet for SIWE authentication. /// The encryption key that is no longer required but was used in the past. Only pass this if you had used custom auth before this was deprecated. /// The wallet secret for backend authentication. + /// The auth token to use for the session. This will automatically connect using a raw thirdweb auth token. /// A task that represents the asynchronous operation. The task result contains the created in-app wallet. /// Thrown when required parameters are not provided. public static async Task Create( @@ -47,11 +48,12 @@ public static async Task Create( string storageDirectoryPath = null, IThirdwebWallet siweSigner = null, string legacyEncryptionKey = null, - string walletSecret = null + string walletSecret = null, + string twAuthTokenOverride = null ) { storageDirectoryPath ??= Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Thirdweb", "InAppWallet"); - var ecoWallet = await Create(client, null, null, email, phoneNumber, authProvider, storageDirectoryPath, siweSigner, legacyEncryptionKey, walletSecret); + var ecoWallet = await Create(client, null, null, email, phoneNumber, authProvider, storageDirectoryPath, siweSigner, legacyEncryptionKey, walletSecret, twAuthTokenOverride); return new InAppWallet( ecoWallet.Client, ecoWallet.EmbeddedWallet,