Skip to content

Commit 98f358d

Browse files
authored
fix: throw if no token is found in local storage (#4961)
1 parent db5457f commit 98f358d

File tree

5 files changed

+17
-3
lines changed

5 files changed

+17
-3
lines changed

.changeset/long-rocks-tan.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
Throw an error if an expected auth token is missing

packages/thirdweb/src/wallets/in-app/web/lib/actions/get-enclave-user-status.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,11 @@ export async function getUserStatus({
3232
);
3333

3434
if (!response.ok) {
35-
console.log("response", response.status);
3635
if (response.status === 401) {
3736
// 401 response indicates there is no user logged in, so we return undefined
3837
return undefined;
3938
}
4039
const result = await response.json();
41-
console.log("result", result);
4240
throw new Error(`Failed to get user status: ${result.error}`);
4341
}
4442

packages/thirdweb/src/wallets/in-app/web/lib/actions/sign-message.enclave.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ export async function signMessage({
2222
const clientFetch = getClientFetch(client, ecosystem);
2323
const authToken = await storage.getAuthCookie();
2424

25+
if (!authToken) {
26+
throw new Error("No auth token found when signing message");
27+
}
28+
2529
const response = await clientFetch(
2630
`${getThirdwebBaseUrl("inAppWallet")}/api/v1/enclave-wallet/sign-message`,
2731
{

packages/thirdweb/src/wallets/in-app/web/lib/actions/sign-transaction.enclave.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,13 @@ export async function signTransaction({
1717
payload: Record<string, Hex | number | undefined>;
1818
storage: ClientScopedStorage;
1919
}) {
20-
console.log("payload", payload);
2120
const clientFetch = getClientFetch(client, ecosystem);
2221
const authToken = await storage.getAuthCookie();
2322

23+
if (!authToken) {
24+
throw new Error("No auth token found when signing transaction");
25+
}
26+
2427
const response = await clientFetch(
2528
`${getThirdwebBaseUrl("inAppWallet")}/api/v1/enclave-wallet/sign-transaction`,
2629
{

packages/thirdweb/src/wallets/in-app/web/lib/actions/sign-typed-data.enclave.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ export async function signTypedData<
2424
const clientFetch = getClientFetch(client, ecosystem);
2525
const authToken = await storage.getAuthCookie();
2626

27+
if (!authToken) {
28+
throw new Error("No auth token found when signing typed data");
29+
}
30+
2731
const response = await clientFetch(
2832
`${getThirdwebBaseUrl("inAppWallet")}/api/v1/enclave-wallet/sign-typed-data`,
2933
{

0 commit comments

Comments
 (0)