Skip to content
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
4 changes: 2 additions & 2 deletions apps/dashboard/src/@/actions/billing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export async function reSubscribePlan(options: {

const res = await fetch(
new URL(
`/v1/teams/${options.teamId}/checkout/resubscribe-plan`,
`/v1/teams/${encodeURIComponent(options.teamId)}/checkout/resubscribe-plan`,
NEXT_PUBLIC_THIRDWEB_API_HOST,
),
{
Expand Down Expand Up @@ -59,7 +59,7 @@ export async function getChainInfraCheckoutURL(options: {

const res = await fetch(
new URL(
`/v1/teams/${options.teamSlug}/checkout/create-link`,
`/v1/teams/${encodeURIComponent(options.teamSlug)}/checkout/create-link`,
NEXT_PUBLIC_THIRDWEB_API_HOST,
),
{
Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/src/@/actions/team/acceptInvite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export async function acceptInvite(options: {
}

const res = await fetch(
`${NEXT_PUBLIC_THIRDWEB_API_HOST}/v1/teams/${options.teamId}/invites/${options.inviteId}/accept`,
`${NEXT_PUBLIC_THIRDWEB_API_HOST}/v1/teams/${encodeURIComponent(options.teamId)}/invites/${encodeURIComponent(options.inviteId)}/accept`,
{
body: JSON.stringify({}),
headers: {
Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/src/@/actions/team/deleteTeam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export async function deleteTeam(options: { teamId: string }) {
}

const res = await fetch(
`${NEXT_PUBLIC_THIRDWEB_API_HOST}/v1/teams/${options.teamId}`,
`${NEXT_PUBLIC_THIRDWEB_API_HOST}/v1/teams/${encodeURIComponent(options.teamId)}`,
{
headers: {
Authorization: `Bearer ${token}`,
Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/src/@/actions/team/sendTeamInvite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async function sendInvite(
token: string,
) {
const res = await fetch(
`${NEXT_PUBLIC_THIRDWEB_API_HOST}/v1/teams/${teamId}/invites`,
`${NEXT_PUBLIC_THIRDWEB_API_HOST}/v1/teams/${encodeURIComponent(teamId)}/invites`,
{
body: JSON.stringify({
inviteEmail: invite.email,
Expand Down
4 changes: 2 additions & 2 deletions apps/dashboard/src/@/api/project/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export async function getProjects(teamSlug: string) {
}

const teamsRes = await fetch(
`${NEXT_PUBLIC_THIRDWEB_API_HOST}/v1/teams/${teamSlug}/projects`,
`${NEXT_PUBLIC_THIRDWEB_API_HOST}/v1/teams/${encodeURIComponent(teamSlug)}/projects`,
{
headers: {
Authorization: `Bearer ${token}`,
Expand All @@ -34,7 +34,7 @@ export async function getProject(teamSlug: string, projectSlug: string) {
}

const teamsRes = await fetch(
`${NEXT_PUBLIC_THIRDWEB_API_HOST}/v1/teams/${teamSlug}/projects/${projectSlug}`,
`${NEXT_PUBLIC_THIRDWEB_API_HOST}/v1/teams/${encodeURIComponent(teamSlug)}/projects/${encodeURIComponent(projectSlug)}`,
{
headers: {
Authorization: `Bearer ${token}`,
Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/src/@/api/team/audit-log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export async function getAuditLogs(teamSlug: string, cursor?: string) {
throw new Error("No auth token found");
}
const url = new URL(
`/v1/teams/${teamSlug}/audit-log`,
`/v1/teams/${encodeURIComponent(teamSlug)}/audit-log`,
NEXT_PUBLIC_THIRDWEB_API_HOST,
);
if (cursor) {
Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/src/@/api/team/dedicated-support.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export async function createDedicatedSupportChannel(

const res = await fetch(
new URL(
`/v1/teams/${teamIdOrSlug}/dedicated-support-channel`,
`/v1/teams/${encodeURIComponent(teamIdOrSlug)}/dedicated-support-channel`,
NEXT_PUBLIC_THIRDWEB_API_HOST,
),
{
Expand Down
4 changes: 2 additions & 2 deletions apps/dashboard/src/@/api/team/verified-domain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export async function checkDomainVerification(
}

const res = await fetch(
`${NEXT_PUBLIC_THIRDWEB_API_HOST}/v1/teams/${teamIdOrSlug}/verified-domain`,
`${NEXT_PUBLIC_THIRDWEB_API_HOST}/v1/teams/${encodeURIComponent(teamIdOrSlug)}/verified-domain`,
{
headers: {
Authorization: `Bearer ${token}`,
Expand All @@ -54,7 +54,7 @@ export async function createDomainVerification(
}

const res = await fetch(
`${NEXT_PUBLIC_THIRDWEB_API_HOST}/v1/teams/${teamIdOrSlug}/verified-domain`,
`${NEXT_PUBLIC_THIRDWEB_API_HOST}/v1/teams/${encodeURIComponent(teamIdOrSlug)}/verified-domain`,
{
body: JSON.stringify({ domain }),
headers: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ export const POST = async (req: NextRequest) => {

const requestBody = (await req.json()) as RequestTestnetFundsPayload;
const { chainId, toAddress, turnstileToken } = requestBody;
if (Number.isNaN(chainId)) {
throw new Error("Invalid chain ID.");
const chainIdStr = String(chainId);
if (!/^[1-9]\d*$/.test(chainIdStr)) {
return NextResponse.json({ error: "Invalid chain ID." }, { status: 400 });
}

if (
Expand Down Expand Up @@ -224,7 +225,7 @@ export const POST = async (req: NextRequest) => {
cacheSet(addressCacheKey, "claimed", 24 * 60 * 60),
]);
// then actually transfer the funds
const url = `${THIRDWEB_ENGINE_URL}/backend-wallet/${chainId}/transfer`;
const url = `${THIRDWEB_ENGINE_URL}/backend-wallet/${chainIdStr}/transfer`;
const response = await fetch(url, {
body: JSON.stringify({
amount: amountToClaim,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export async function createEcosystem(options: {
});

const res = await fetch(
`${NEXT_PUBLIC_THIRDWEB_API_HOST}/v1/teams/${teamSlug}/checkout/create-link`,
`${NEXT_PUBLIC_THIRDWEB_API_HOST}/v1/teams/${encodeURIComponent(teamSlug)}/checkout/create-link`,
{
body: JSON.stringify({
baseUrl: BASE_URL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export async function updateTeam(params: {
}

const res = await fetch(
`${NEXT_PUBLIC_THIRDWEB_API_HOST}/v1/teams/${params.teamId}`,
`${NEXT_PUBLIC_THIRDWEB_API_HOST}/v1/teams/${encodeURIComponent(params.teamId)}`,
{
body: JSON.stringify(params.value),
headers: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"use server";

import "server-only";
import { getAuthToken } from "@/api/auth-token";
import type { Project } from "@/api/project/projects";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export async function updateSession(params: {

const res = await fetchWithAuthToken({
body: body,
endpoint: `${NEXT_PUBLIC_THIRDWEB_AI_HOST}/session/${params.sessionId}`,
endpoint: `${NEXT_PUBLIC_THIRDWEB_AI_HOST}/session/${encodeURIComponent(params.sessionId)}`,
method: "PUT",
project: params.project,
});
Expand All @@ -76,7 +76,7 @@ export async function deleteSession(params: {
sessionId: string;
}) {
const res = await fetchWithAuthToken({
endpoint: `${NEXT_PUBLIC_THIRDWEB_AI_HOST}/session/${params.sessionId}`,
endpoint: `${NEXT_PUBLIC_THIRDWEB_AI_HOST}/session/${encodeURIComponent(params.sessionId)}`,
method: "DELETE",
project: params.project,
});
Expand Down Expand Up @@ -109,7 +109,7 @@ export async function getSessionById(params: {
sessionId: string;
}) {
const res = await fetchWithAuthToken({
endpoint: `${NEXT_PUBLIC_THIRDWEB_AI_HOST}/session/${params.sessionId}`,
endpoint: `${NEXT_PUBLIC_THIRDWEB_AI_HOST}/session/${encodeURIComponent(params.sessionId)}`,
method: "GET",
project: params.project,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function createRandomSessions(length: number) {
for (let i = 0; i < length; i++) {
sessions.push({
created_at: new Date().toISOString(),
id: Math.random().toString(),
id: crypto.randomUUID(),
title: randomLorem(Math.floor(5 + Math.random() * 15)),
updated_at: subDays(
new Date(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ export function LaunchTokenStatus(props: {
}

const contractLink = contractAddress
? `/team/${props.teamSlug}/${props.projectSlug}/contract/${formValues.chain}/${contractAddress}`
? `/team/${props.teamSlug}/${props.projectSlug}/contract/${encodeURIComponent(formValues.chain)}/${encodeURIComponent(contractAddress)}`
: null;

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function createRandomSessions(length: number) {
for (let i = 0; i < length; i++) {
sessions.push({
created_at: new Date().toISOString(),
id: Math.random().toString(),
id: crypto.randomUUID(),
title: randomLorem(Math.floor(5 + Math.random() * 15)),
updated_at: subDays(
new Date(),
Expand Down
2 changes: 1 addition & 1 deletion apps/wallet-ui/src/lib/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export async function getChains() {

export async function getChain(chainIdOrSlug: string): Promise<ChainMetadata> {
const res = await fetch(
`https://api.thirdweb.com/v1/chains/${chainIdOrSlug}`,
`https://api.thirdweb.com/v1/chains/${encodeURIComponent(chainIdOrSlug)}`,
// revalidate every 15 minutes
{ next: { revalidate: 15 * 60 } },
);
Expand Down
Loading