Skip to content

Commit 325625a

Browse files
authored
Allow login with tw auth token (#129)
1 parent 6b4afc1 commit 325625a

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

Thirdweb/Thirdweb.Wallets/InAppWallet/EcosystemWallet/EcosystemWallet.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ string walletSecret
8080
/// <param name="siweSigner">The SIWE signer wallet for SIWE authentication.</param>
8181
/// <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>
8282
/// <param name="walletSecret">The wallet secret for Backend authentication.</param>
83+
/// <param name="twAuthTokenOverride">The auth token to use for the session. This will automatically connect using a raw thirdweb auth token.</param>
8384
/// <returns>A task that represents the asynchronous operation. The task result contains the created in-app wallet.</returns>
8485
/// <exception cref="ArgumentException">Thrown when required parameters are not provided.</exception>
8586
public static async Task<EcosystemWallet> Create(
@@ -92,7 +93,8 @@ public static async Task<EcosystemWallet> Create(
9293
string storageDirectoryPath = null,
9394
IThirdwebWallet siweSigner = null,
9495
string legacyEncryptionKey = null,
95-
string walletSecret = null
96+
string walletSecret = null,
97+
string twAuthTokenOverride = null
9698
)
9799
{
98100
if (client == null)
@@ -154,6 +156,10 @@ public static async Task<EcosystemWallet> Create(
154156

155157
storageDirectoryPath ??= Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Thirdweb", "EcosystemWallet");
156158
var embeddedWallet = new EmbeddedWallet(client, storageDirectoryPath, ecosystemId, ecosystemPartnerId);
159+
if (!string.IsNullOrWhiteSpace(twAuthTokenOverride))
160+
{
161+
CreateEnclaveSession(embeddedWallet, twAuthTokenOverride, email, phoneNumber, authproviderStr, null);
162+
}
157163

158164
try
159165
{

Thirdweb/Thirdweb.Wallets/InAppWallet/InAppWallet.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ string walletSecret
3737
/// <param name="siweSigner">The SIWE signer wallet for SIWE authentication.</param>
3838
/// <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>
3939
/// <param name="walletSecret">The wallet secret for backend authentication.</param>
40+
/// <param name="twAuthTokenOverride">The auth token to use for the session. This will automatically connect using a raw thirdweb auth token.</param>
4041
/// <returns>A task that represents the asynchronous operation. The task result contains the created in-app wallet.</returns>
4142
/// <exception cref="ArgumentException">Thrown when required parameters are not provided.</exception>
4243
public static async Task<InAppWallet> Create(
@@ -47,11 +48,12 @@ public static async Task<InAppWallet> Create(
4748
string storageDirectoryPath = null,
4849
IThirdwebWallet siweSigner = null,
4950
string legacyEncryptionKey = null,
50-
string walletSecret = null
51+
string walletSecret = null,
52+
string twAuthTokenOverride = null
5153
)
5254
{
5355
storageDirectoryPath ??= Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Thirdweb", "InAppWallet");
54-
var ecoWallet = await Create(client, null, null, email, phoneNumber, authProvider, storageDirectoryPath, siweSigner, legacyEncryptionKey, walletSecret);
56+
var ecoWallet = await Create(client, null, null, email, phoneNumber, authProvider, storageDirectoryPath, siweSigner, legacyEncryptionKey, walletSecret, twAuthTokenOverride);
5557
return new InAppWallet(
5658
ecoWallet.Client,
5759
ecoWallet.EmbeddedWallet,

0 commit comments

Comments
 (0)