Skip to content

Allow login with tw auth token #129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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