Skip to content

Commit

Permalink
Allow login with tw auth token (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xFirekeeper authored Feb 13, 2025
1 parent 6b4afc1 commit 325625a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ string walletSecret
/// <param name="siweSigner">The SIWE signer wallet for SIWE authentication.</param>
/// <param name="legacyEncryptionKey">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.</param>
/// <param name="walletSecret">The wallet secret for Backend authentication.</param>
/// <param name="twAuthTokenOverride">The auth token to use for the session. This will automatically connect using a raw thirdweb auth token.</param>
/// <returns>A task that represents the asynchronous operation. The task result contains the created in-app wallet.</returns>
/// <exception cref="ArgumentException">Thrown when required parameters are not provided.</exception>
public static async Task<EcosystemWallet> Create(
Expand All @@ -92,7 +93,8 @@ public static async Task<EcosystemWallet> Create(
string storageDirectoryPath = null,
IThirdwebWallet siweSigner = null,
string legacyEncryptionKey = null,
string walletSecret = null
string walletSecret = null,
string twAuthTokenOverride = null
)
{
if (client == null)
Expand Down Expand Up @@ -154,6 +156,10 @@ public static async Task<EcosystemWallet> 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
{
Expand Down
6 changes: 4 additions & 2 deletions Thirdweb/Thirdweb.Wallets/InAppWallet/InAppWallet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ string walletSecret
/// <param name="siweSigner">The SIWE signer wallet for SIWE authentication.</param>
/// <param name="legacyEncryptionKey">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.</param>
/// <param name="walletSecret">The wallet secret for backend authentication.</param>
/// <param name="twAuthTokenOverride">The auth token to use for the session. This will automatically connect using a raw thirdweb auth token.</param>
/// <returns>A task that represents the asynchronous operation. The task result contains the created in-app wallet.</returns>
/// <exception cref="ArgumentException">Thrown when required parameters are not provided.</exception>
public static async Task<InAppWallet> Create(
Expand All @@ -47,11 +48,12 @@ public static async Task<InAppWallet> 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,
Expand Down

0 comments on commit 325625a

Please sign in to comment.