The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Merge branch 'main' into ai-link-creation
flooorianflo1cf1c52d9123
diff --git a/apps/docs/api-reference/endpoint/retrieve-metatags.mdx b/apps/docs/api-reference/endpoint/retrieve-metatags.mdxnew file mode 100644index 0000000000..0bc0651241--- /dev/null+++ b/apps/docs/api-reference/endpoint/retrieve-metatags.mdx@@ -0,0 +1,3 @@+---+openapi: get /metatags+---diff --git a/apps/docs/mint.json b/apps/docs/mint.jsonindex 70e3e40e98..7cd364a893 100644--- a/apps/docs/mint.json+++ b/apps/docs/mint.json@@ -110,6 +110,10 @@"api-reference/endpoint/create-a-new-tag","api-reference/endpoint/retrieve-a-list-of-tags"]+ },+ {+ "group": "Metatags",+ "pages": ["api-reference/endpoint/retrieve-metatags"]}],"api": {diff --git a/apps/web/app/api/admin/analytics/[endpoint]/route.ts b/apps/web/app/api/admin/analytics/[endpoint]/route.tsindex e77e7f4adb..ff5c41cb5d 100644--- a/apps/web/app/api/admin/analytics/[endpoint]/route.ts+++ b/apps/web/app/api/admin/analytics/[endpoint]/route.ts@@ -3,7 +3,7 @@ import { withAdmin } from "@/lib/auth";import {analyticsEndpointSchema,getAnalyticsQuerySchema,-} from "@/lib/zod/schemas/analytics";+} from "@/lib/zod/schemas";import { NextResponse } from "next/server";// GET /api/admin/analytics/[endpoint] – get analytics for a specific endpointdiff --git a/apps/web/app/api/analytics/[endpoint]/route.ts b/apps/web/app/api/analytics/[endpoint]/route.tsindex b1e3246985..c3f8ca2766 100644--- a/apps/web/app/api/analytics/[endpoint]/route.ts+++ b/apps/web/app/api/analytics/[endpoint]/route.ts@@ -5,7 +5,7 @@ import { getDomainViaEdge } from "@/lib/planetscale";import {analyticsEndpointSchema,getAnalyticsQuerySchema,-} from "@/lib/zod/schemas/analytics";+} from "@/lib/zod/schemas";import { NextResponse } from "next/server";// GET /api/analytics/[endpoint] – get analytics for a specific endpointdiff --git a/apps/web/app/api/analytics/edge/[endpoint]/route.ts b/apps/web/app/api/analytics/edge/[endpoint]/route.tsindex b5a62315fd..e46739d145 100644--- a/apps/web/app/api/analytics/edge/[endpoint]/route.ts+++ b/apps/web/app/api/analytics/edge/[endpoint]/route.ts@@ -4,13 +4,13 @@ import {exceededLimitError,handleAndReturnErrorResponse,} from "@/lib/api/errors";-import { getIdentityHash } from "@/lib/edge";+import { getIdentityHash } from "@/lib/middleware/utils";import { getDomainOrLink, getWorkspaceViaEdge } from "@/lib/planetscale";import { ratelimit } from "@/lib/upstash";import {analyticsEndpointSchema,getAnalyticsEdgeQuerySchema,-} from "@/lib/zod/schemas/analytics";+} from "@/lib/zod/schemas";import { DUB_DEMO_LINKS, DUB_WORKSPACE_ID, getSearchParams } from "@dub/utils";import { NextResponse, type NextRequest } from "next/server";diff --git a/apps/web/app/api/analytics/export/route.ts b/apps/web/app/api/analytics/export/route.tsindex 0b43f110d2..b9d0b58cb2 100644--- a/apps/web/app/api/analytics/export/route.ts+++ b/apps/web/app/api/analytics/export/route.ts@@ -3,7 +3,7 @@ import { DubApiError } from "@/lib/api/errors";import { withAuth } from "@/lib/auth";import { getDomainViaEdge } from "@/lib/planetscale";import prisma from "@/lib/prisma";-import { getAnalyticsQuerySchema } from "@/lib/zod/schemas/analytics";+import { getAnalyticsQuerySchema } from "@/lib/zod/schemas";import { linkConstructor } from "@dub/utils";import { json2csv } from "json-2-csv";import JSZip from "jszip";diff --git a/apps/web/app/api/analytics/route.ts b/apps/web/app/api/analytics/route.tsindex 391c5acdd2..a4815515c6 100644--- a/apps/web/app/api/analytics/route.ts+++ b/apps/web/app/api/analytics/route.ts@@ -1,7 +1,8 @@import { withAuth } from "@/lib/auth";import { getDomainOrLink } from "@/lib/planetscale";import prisma from "@/lib/prisma";-import z, { domainKeySchema } from "@/lib/zod";+import z from "@/lib/zod";+import { domainKeySchema } from "@/lib/zod/schemas";import { NextResponse } from "next/server";const updatePublicStatsSchema = z.object({diff --git a/apps/web/app/api/auth/account-exists/route.ts b/apps/web/app/api/auth/account-exists/route.tsindex fb6d3a8234..3a86387676 100644--- a/apps/web/app/api/auth/account-exists/route.ts+++ b/apps/web/app/api/auth/account-exists/route.ts@@ -1,5 +1,5 @@-import { getIdentityHash } from "@/lib/edge";import { isWhitelistedEmail } from "@/lib/edge-config";+import { getIdentityHash } from "@/lib/middleware/utils";import { DATABASE_URL, conn } from "@/lib/planetscale";import { ratelimit } from "@/lib/upstash";import { NextRequest, NextResponse } from "next/server";diff --git a/apps/web/app/api/links/[linkId]/route.ts b/apps/web/app/api/links/[linkId]/route.tsindex 9cf6b3b9e4..0e58921952 100644--- a/apps/web/app/api/links/[linkId]/route.ts+++ b/apps/web/app/api/links/[linkId]/route.ts@@ -3,7 +3,7 @@ import { deleteLink, editLink, processLink } from "@/lib/api/links";import { withAuth } from "@/lib/auth";import prisma from "@/lib/prisma";import { LinkWithTagIdsProps } from "@/lib/types";-import { updateLinkBodySchema } from "@/lib/zod/schemas/links";+import { updateLinkBodySchema } from "@/lib/zod/schemas";import { NextResponse } from "next/server";// GET /api/links/[linkId] – get a linkdiff --git a/apps/web/app/api/links/bulk/route.ts b/apps/web/app/api/links/bulk/route.tsindex d5b5621c13..6b42df5063 100644--- a/apps/web/app/api/links/bulk/route.ts+++ b/apps/web/app/api/links/bulk/route.ts@@ -3,7 +3,7 @@ import { bulkCreateLinks, combineTagIds, processLink } from "@/lib/api/links";import { withAuth } from "@/lib/auth";import prisma from "@/lib/prisma";import { LinkWithTagIdsProps } from "@/lib/types";-import { bulkCreateLinksBodySchema } from "@/lib/zod/schemas/links";+import { bulkCreateLinksBodySchema } from "@/lib/zod/schemas";import { NextResponse } from "next/server";// POST /api/links/bulk – bulk create up to 100 linksdiff --git a/apps/web/app/api/links/count/route.ts b/apps/web/app/api/links/count/route.tsindex 0be72b826a..c1edd6a8c0 100644--- a/apps/web/app/api/links/count/route.ts+++ b/apps/web/app/api/links/count/route.ts@@ -1,6 +1,6 @@import { getLinksCount } from "@/lib/api/links";import { withAuth } from "@/lib/auth";-import { getLinksCountQuerySchema } from "@/lib/zod/schemas/links";+import { getLinksCountQuerySchema } from "@/lib/zod/schemas";import { NextResponse } from "next/server";// GET /api/links/count – get the number of links for a workspacediff --git a/apps/web/app/api/links/iframeable/route.ts b/apps/web/app/api/links/iframeable/route.tsindex a58ea20eae..73b3085434 100644--- a/apps/web/app/api/links/iframeable/route.ts+++ b/apps/web/app/api/links/iframeable/route.ts@@ -1,10 +1,7 @@import { DubApiError, handleAndReturnErrorResponse } from "@/lib/api/errors";-import { getIdentityHash } from "@/lib/edge";+import { getIdentityHash } from "@/lib/middleware/utils";import { ratelimit } from "@/lib/upstash";-import {- getDomainQuerySchema,- getUrlQuerySchema,-} from "@/lib/zod/schemas/links";+import { getDomainQuerySchema, getUrlQuerySchema } from "@/lib/zod/schemas";import { isIframeable } from "@dub/utils";import { getToken } from "next-auth/jwt";import { NextRequest, NextResponse } from "next/server";diff --git a/apps/web/app/api/links/info/route.ts b/apps/web/app/api/links/info/route.tsindex 778d560d86..9ad7955986 100644--- a/apps/web/app/api/links/info/route.ts+++ b/apps/web/app/api/links/info/route.ts@@ -2,12 +2,12 @@ import { DubApiError } from "@/lib/api/errors";import { transformLink } from "@/lib/api/links";import { withAuth } from "@/lib/auth";import prisma from "@/lib/prisma";-import { getLinkInfoQuerySchema } from "@/lib/zod/schemas/links";+import { domainKeySchema } from "@/lib/zod/schemas";import { NextResponse } from "next/server";// GET /api/links/info – get the info for a linkexport const GET = withAuth(async ({ headers, searchParams }) => {- const { domain, key } = getLinkInfoQuerySchema.parse(searchParams);+ const { domain, key } = domainKeySchema.parse(searchParams);const link = await prisma.link.findUnique({where: {diff --git a/apps/web/app/api/links/random/route.ts b/apps/web/app/api/links/random/route.tsindex 362ffbf44d..e7400a8a28 100644--- a/apps/web/app/api/links/random/route.ts+++ b/apps/web/app/api/links/random/route.ts@@ -1,8 +1,8 @@import { DubApiError, handleAndReturnErrorResponse } from "@/lib/api/errors";-import { getIdentityHash } from "@/lib/edge";+import { getIdentityHash } from "@/lib/middleware/utils";import { getRandomKey } from "@/lib/planetscale";import { ratelimit } from "@/lib/upstash";-import { domainKeySchema } from "@/lib/zod";+import { domainKeySchema } from "@/lib/zod/schemas";import { getSearchParams } from "@dub/utils";import { getToken } from "next-auth/jwt";import { NextRequest, NextResponse } from "next/server";diff --git a/apps/web/app/api/links/route.ts b/apps/web/app/api/links/route.tsindex 62ad270650..9f4629bb9e 100644--- a/apps/web/app/api/links/route.ts+++ b/apps/web/app/api/links/route.ts@@ -3,10 +3,7 @@ import { createLink, getLinksForWorkspace, processLink } from "@/lib/api/links";import { withAuth } from "@/lib/auth";import { LinkWithTagIdsProps } from "@/lib/types";import { ratelimit } from "@/lib/upstash";-import {- createLinkBodySchema,- getLinksQuerySchema,-} from "@/lib/zod/schemas/links";+import { createLinkBodySchema, getLinksQuerySchema } from "@/lib/zod/schemas";import { LOCALHOST_IP } from "@dub/utils";import { NextResponse } from "next/server";diff --git a/apps/web/app/api/links/verify/route.ts b/apps/web/app/api/links/verify/route.tsnew file mode 100644index 0000000000..f6ffb17817--- /dev/null+++ b/apps/web/app/api/links/verify/route.ts@@ -0,0 +1,55 @@+import { DubApiError, handleAndReturnErrorResponse } from "@/lib/api/errors";+import { keyChecks, processKey } from "@/lib/api/links";+import { getWorkspaceViaEdge } from "@/lib/planetscale";+import { workspaceIdSchema } from "@/lib/zod";+import { domainKeySchema } from "@/lib/zod/schemas";+import { getSearchParams } from "@dub/utils";+import { NextRequest, NextResponse } from "next/server";++export const runtime = "edge";++// GET /api/links/verify – run keyChecks on the key+export const GET = async (req: NextRequest) => {+ try {+ const searchParams = getSearchParams(req.url);++ let { domain, key, workspaceId } = domainKeySchema+ .and(workspaceIdSchema)+ .parse(searchParams);++ const processedKey = processKey(key);+ if (processedKey === null) {+ throw new DubApiError({+ code: "unprocessable_entity",+ message: "Invalid key.",+ });+ }+ key = processedKey;++ const workspace = await getWorkspaceViaEdge(workspaceId);++ if (!workspace) {+ throw new DubApiError({+ code: "not_found",+ message: "Workspace not found.",+ });+ }++ const response = await keyChecks({+ domain,+ key,+ workspace,+ });++ if (response.error) {+ throw new DubApiError({+ code: "unprocessable_entity",+ message: response.error,+ });+ }++ return NextResponse.json(response);+ } catch (error) {+ return handleAndReturnErrorResponse(error);+ }+};diff --git a/apps/web/app/api/metatags/route.ts b/apps/web/app/api/metatags/route.tsindex d8647a0b9f..1096583d7f 100644--- a/apps/web/app/api/metatags/route.ts+++ b/apps/web/app/api/metatags/route.ts@@ -1,7 +1,7 @@import { DubApiError, handleAndReturnErrorResponse } from "@/lib/api/errors";-import { getIdentityHash } from "@/lib/edge";+import { getIdentityHash } from "@/lib/middleware/utils";import { ratelimit } from "@/lib/upstash";-import { getUrlQuerySchema } from "@/lib/zod/schemas/links";+import { getUrlQuerySchema } from "@/lib/zod/schemas";import { getToken } from "next-auth/jwt";import { NextRequest, NextResponse } from "next/server";import { getMetaTags } from "./utils";diff --git a/apps/web/app/api/providers/route.ts b/apps/web/app/api/providers/route.tsindex f794625f41..863c9edd87 100644--- a/apps/web/app/api/providers/route.ts+++ b/apps/web/app/api/providers/route.ts@@ -1,7 +1,7 @@import { handleAndReturnErrorResponse } from "@/lib/api/errors";-import { getIdentityHash } from "@/lib/edge";+import { getIdentityHash } from "@/lib/middleware/utils";import { ratelimit } from "@/lib/upstash";-import { getUrlQuerySchema } from "@/lib/zod/schemas/links";+import { getUrlQuerySchema } from "@/lib/zod/schemas";import { fetchWithTimeout } from "@dub/utils";import { getToken } from "next-auth/jwt";import { NextRequest, NextResponse } from "next/server";diff --git a/apps/web/app/api/qr/route.tsx b/apps/web/app/api/qr/route.tsxindex 4b5e4bb9a5..139de74abf 100644--- a/apps/web/app/api/qr/route.tsx+++ b/apps/web/app/api/qr/route.tsx@@ -1,8 +1,8 @@import { DubApiError, handleAndReturnErrorResponse } from "@/lib/api/errors";-import { getIdentityHash } from "@/lib/edge";+import { getIdentityHash } from "@/lib/middleware/utils";import { QRCodeSVG } from "@/lib/qr/utils";import { ratelimit } from "@/lib/upstash";-import { getQRCodeQuerySchema } from "@/lib/zod/schemas/qr";+import { getQRCodeQuerySchema } from "@/lib/zod/schemas";import { getSearchParams } from "@dub/utils";import { getToken } from "next-auth/jwt";import { ImageResponse } from "next/og";diff --git a/apps/web/app/api/tags/[id]/route.ts b/apps/web/app/api/tags/[id]/route.tsindex 68689002da..e29af52fbe 100644--- a/apps/web/app/api/tags/[id]/route.ts+++ b/apps/web/app/api/tags/[id]/route.ts@@ -2,7 +2,7 @@ import { DubApiError } from "@/lib/api/errors";import { withAuth } from "@/lib/auth";import prisma from "@/lib/prisma";import { recordLink } from "@/lib/tinybird";-import { updateTagBodySchema } from "@/lib/zod/schemas/tags";+import { updateTagBodySchema } from "@/lib/zod/schemas";import { NextResponse } from "next/server";// PUT /api/workspaces/[idOrSlug]/tags/[id] – update a tag for a workspacediff --git a/apps/web/app/api/tags/route.ts b/apps/web/app/api/tags/route.tsindex 71fcef56b4..13af3b4287 100644--- a/apps/web/app/api/tags/route.ts+++ b/apps/web/app/api/tags/route.ts@@ -1,7 +1,7 @@import { DubApiError, exceededLimitError } from "@/lib/api/errors";import { withAuth } from "@/lib/auth";import prisma from "@/lib/prisma";-import { createTagBodySchema } from "@/lib/zod/schemas/tags";+import { createTagBodySchema } from "@/lib/zod/schemas";import { COLORS_LIST, randomBadgeColor } from "@/ui/links/tag-badge";import { NextResponse } from "next/server";diff --git a/apps/web/app/api/unsplash/search/route.ts b/apps/web/app/api/unsplash/search/route.tsindex cdab93ada2..21fe87cf5e 100644--- a/apps/web/app/api/unsplash/search/route.ts+++ b/apps/web/app/api/unsplash/search/route.ts@@ -1,4 +1,4 @@-import { getIdentityHash } from "@/lib/edge";+import { getIdentityHash } from "@/lib/middleware/utils";import { ratelimit } from "@/lib/upstash";import { NextResponse } from "next/server";import { unsplash } from "../utils";diff --git a/apps/web/app/api/workspaces/[idOrSlug]/route.ts b/apps/web/app/api/workspaces/[idOrSlug]/route.tsindex 50e50ae37e..1819be7ecc 100644--- a/apps/web/app/api/workspaces/[idOrSlug]/route.ts+++ b/apps/web/app/api/workspaces/[idOrSlug]/route.ts@@ -4,21 +4,30 @@ import { withAuth } from "@/lib/auth";import { isReservedKey } from "@/lib/edge-config";import prisma from "@/lib/prisma";import z from "@/lib/zod";-import { DEFAULT_REDIRECTS, validSlugRegex } from "@dub/utils";+import { DEFAULT_REDIRECTS, trim, validSlugRegex } from "@dub/utils";import slugify from "@sindresorhus/slugify";import { NextResponse } from "next/server";const updateWorkspaceSchema = z.object({- name: z.string().min(1).max(32).optional(),+ name: z.preprocess(trim, z.string().min(1).max(32)).optional(),slug: z- .string()- .min(3, "Slug must be at least 3 characters")- .max(48, "Slug must be less than 48 characters")- .transform((v) => slugify(v))- .refine((v) => validSlugRegex.test(v), { message: "Invalid slug format" })- .refine(async (v) => !((await isReservedKey(v)) || DEFAULT_REDIRECTS[v]), {- message: "Cannot use reserved slugs",- })+ .preprocess(+ trim,+ z+ .string()+ .min(3, "Slug must be at least 3 characters")+ .max(48, "Slug must be less than 48 characters")+ .transform((v) => slugify(v))+ .refine((v) => validSlugRegex.test(v), {+ message: "Invalid slug format",+ })+ .refine(+ async (v) => !((await isReservedKey(v)) || DEFAULT_REDIRECTS[v]),+ {+ message: "Cannot use reserved slugs",+ },+ ),+ ).optional(),});diff --git a/apps/web/app/api/workspaces/route.ts b/apps/web/app/api/workspaces/route.tsindex a4bbc3a358..86cb0cebbc 100644--- a/apps/web/app/api/workspaces/route.ts+++ b/apps/web/app/api/workspaces/route.ts@@ -6,7 +6,7 @@ import {import { DubApiError } from "@/lib/api/errors";import { withSession } from "@/lib/auth";import prisma from "@/lib/prisma";-import { createWorkspaceSchema } from "@/lib/zod/schemas/workspaces";+import { createWorkspaceSchema } from "@/lib/zod/schemas";import { FREE_WORKSPACES_LIMIT, nanoid } from "@dub/utils";import { NextResponse } from "next/server";diff --git a/apps/web/app/app.dub.co/(auth)/login/form.tsx b/apps/web/app/app.dub.co/(auth)/login/form.tsxindex e28d914346..b337f2c653 100644--- a/apps/web/app/app.dub.co/(auth)/login/form.tsx+++ b/apps/web/app/app.dub.co/(auth)/login/form.tsx@@ -15,7 +15,7 @@ export default function LoginForm() {const [noSuchAccount, setNoSuchAccount] = useState(false);const [email, setEmail] = useState("");const [clickedGoogle, setClickedGoogle] = useState(false);- const [clickedGitub, setClickedGithub] = useState(false);+ const [clickedGithub, setClickedGithub] = useState(false);const [clickedEmail, setClickedEmail] = useState(false);const [clickedSSO, setClickedSSO] = useState(false);@@ -59,7 +59,7 @@ export default function LoginForm() {...(next && next.length > 0 ? { callbackUrl: next } : {}),});}}- loading={clickedGitub}+ loading={clickedGithub}disabled={clickedEmail || clickedSSO}icon={<Github className="h-5 w-5 text-black" />}/>diff --git a/apps/web/app/app.dub.co/(auth)/register/form.tsx b/apps/web/app/app.dub.co/(auth)/register/form.tsxindex f637a2b605..4e6c515b01 100644--- a/apps/web/app/app.dub.co/(auth)/register/form.tsx+++ b/apps/web/app/app.dub.co/(auth)/register/form.tsx@@ -10,7 +10,7 @@ export default function RegisterForm() {const searchParams = useSearchParams();const next = searchParams?.get("next");const [clickedGoogle, setClickedGoogle] = useState(false);- const [clickedGitub, setClickedGithub] = useState(false);+ const [clickedGithub, setClickedGithub] = useState(false);useEffect(() => {// when leave page, reset state@@ -42,7 +42,7 @@ export default function RegisterForm() {...(next && next.length > 0 ? { callbackUrl: next } : {}),});}}- loading={clickedGitub}+ loading={clickedGithub}icon={<Github className="h-4 w-4" />}/><p className="text-center text-sm text-gray-500">diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/page-client.tsxindex 16cf5b1620..5a2a40a221 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/page-client.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/page-client.tsx@@ -43,11 +43,9 @@ export default function WorkspaceSettingsClient() {mutate(`/api/workspaces/${id}`),]);toast.success("Successfully updated workspace name!");- } else if (res.status === 422) {- toast.error("Workspace slug already exists");} else {- const errorMessage = await res.text();- toast.error(errorMessage || "Something went wrong");+ const { error } = await res.json();+ toast.error(error.message);}})}@@ -81,8 +79,8 @@ export default function WorkspaceSettingsClient() {router.push(`/${newSlug}/settings`);toast.success("Successfully updated workspace slug!");} else {- const error = await res.text();- toast.error(error || "Something went wrong");+ const { error } = await res.json();+ toast.error(error.message);}})}diff --git a/apps/web/app/app.dub.co/(redirects)/_loading.tsx b/apps/web/app/app.dub.co/(redirects)/loading.tsxsimilarity index 100%rename from apps/web/app/app.dub.co/(redirects)/_loading.tsxrename to apps/web/app/app.dub.co/(redirects)/loading.tsxdiff --git a/apps/web/app/layout.tsx b/apps/web/app/layout.tsxindex bacf16461d..1ecdcb6ea4 100644--- a/apps/web/app/layout.tsx+++ b/apps/web/app/layout.tsx@@ -17,7 +17,7 @@ export default function RootLayout({<html lang="en" className={cn(satoshi.variable, inter.variable)}><body><TooltipProvider>- <Toaster closeButton />+ <Toaster className="pointer-events-auto" />{children}<Analytics /><SpeedInsights />diff --git a/apps/web/emails/index.ts b/apps/web/emails/index.tsindex 61c1fe7548..f9b3cc59fa 100644--- a/apps/web/emails/index.ts+++ b/apps/web/emails/index.ts@@ -2,7 +2,9 @@ import { render } from "@react-email/render";import { Client } from "postmark";import { JSXElementConstructor, ReactElement } from "react";-export const client = new Client(process.env.POSTMARK_API_KEY as string);+export const client = process.env.POSTMARK_API_KEY+ ? new Client(process.env.POSTMARK_API_KEY)+ : null;export const sendEmail = async ({email,@@ -19,8 +21,16 @@ export const sendEmail = async ({react?: ReactElement<any, string | JSXElementConstructor<any>>;marketing?: boolean;}) => {- if (!process.env.POSTMARK_API_KEY) {- console.log(+ if (process.env.NODE_ENV === "development" && !client) {+ // Set up a fake email client for development+ console.info(+ `Email to ${email} with subject ${subject} sent from ${+ from || process.env.NEXT_PUBLIC_APP_NAME+ }`,+ );+ return Promise.resolve();+ } else if (!client) {+ console.error("Postmark is not configured. You need to add a POSTMARK_API_KEY in your .env file for emails to work.",);return Promise.resolve();diff --git a/apps/web/lib/api/links/get-links-count.ts b/apps/web/lib/api/links/get-links-count.tsindex e36c68cd00..fc2eccc77e 100644--- a/apps/web/lib/api/links/get-links-count.ts+++ b/apps/web/lib/api/links/get-links-count.ts@@ -1,6 +1,6 @@import prisma from "@/lib/prisma";import z from "@/lib/zod";-import { getLinksCountQuerySchema } from "@/lib/zod/schemas/links";+import { getLinksCountQuerySchema } from "@/lib/zod/schemas";import { combineTagIds } from "./utils";export async function getLinksCount({diff --git a/apps/web/lib/api/links/get-links-for-workspace.ts b/apps/web/lib/api/links/get-links-for-workspace.tsindex a11190135d..59c961ae5e 100644--- a/apps/web/lib/api/links/get-links-for-workspace.ts+++ b/apps/web/lib/api/links/get-links-for-workspace.ts@@ -1,6 +1,6 @@import prisma from "@/lib/prisma";import z from "@/lib/zod";-import { getLinksQuerySchema } from "@/lib/zod/schemas/links";+import { getLinksQuerySchema } from "@/lib/zod/schemas";import { combineTagIds, transformLink } from "./utils";export async function getLinksForWorkspace({diff --git a/apps/web/lib/api/links/process-link.ts b/apps/web/lib/api/links/process-link.tsindex 1ed37b3876..441c85d637 100644--- a/apps/web/lib/api/links/process-link.ts+++ b/apps/web/lib/api/links/process-link.ts@@ -74,10 +74,23 @@ export async function processLink({code: "forbidden",};} else if (password || rewrite || expiresAt || ios || android || geo) {+ const proFeaturesString = [+ proxy && "custom social media cards",+ password && "password protection",+ rewrite && "link cloaking",+ expiresAt && "link expiration",+ ios && "iOS targeting",+ android && "Android targeting",+ geo && "geo targeting",+ ]+ .filter(Boolean)+ .join(", ")+ // final one should be "and" instead of comma+ .replace(/, ([^,]*)$/, " and $1");+return {link: payload,- error:- "You can only use custom social media cards, password-protection, link cloaking, link expiration, device and geo targeting on a Pro plan and above. Upgrade to Pro to use these features.",+ error: `You can only use ${proFeaturesString} on a Pro plan and above. Upgrade to Pro to use these features.`,code: "forbidden",};}diff --git a/apps/web/lib/api/links/utils.ts b/apps/web/lib/api/links/utils.tsindex 3493f9ba41..c18bc9b120 100644--- a/apps/web/lib/api/links/utils.ts+++ b/apps/web/lib/api/links/utils.ts@@ -9,6 +9,7 @@ import {isDubDomain,linkConstructor,log,+ punyEncode,validKeyRegex,} from "@dub/utils";import { Link, Tag } from "@prisma/client";@@ -105,6 +106,8 @@ export function processKey(key: string) {key = key.replace(/^\/+|\/+$/g, "");// replace all special characterskey = key.normalize("NFD").replace(/[\u0300-\u036f]/g, "");+ // encode the key to ascii+ key = punyEncode(key);return key;}@@ -133,12 +136,20 @@ export const transformLink = (link: LinkWithTags) => {key: link.key,});+ const qrLink = linkConstructor({+ domain: link.domain,+ key: link.key,+ searchParams: {+ qr: "1",+ },+ });+return {...link,shortLink,tagId: tags?.[0]?.id ?? null, // backwards compatibilitytags,- qrCode: `https://api.dub.co/qr?url=${shortLink}`,+ qrCode: `https://api.dub.co/qr?url=${qrLink}`,workspaceId: `ws_${link.projectId}`,};};diff --git a/apps/web/lib/middleware/link.ts b/apps/web/lib/middleware/link.tsindex 827eb695e8..11e0adc669 100644--- a/apps/web/lib/middleware/link.ts+++ b/apps/web/lib/middleware/link.ts@@ -6,6 +6,7 @@ import {DUB_HEADERS,LEGAL_WORKSPACE_ID,LOCALHOST_GEO_DATA,+ punyEncode,} from "@dub/utils";import {NextFetchEvent,@@ -27,8 +28,9 @@ export default async function LinkMiddleware(return NextResponse.next();}+ // encode the key to ascii// links on Dub are case insensitive by default- key = key.toLowerCase();+ key = punyEncode(key.toLowerCase());const demoLink = DUB_DEMO_LINKS.find((l) => l.domain === domain && l.key === key,diff --git a/apps/web/lib/middleware/utils.ts b/apps/web/lib/middleware/utils.tsdeleted file mode 100644index 554caeefa6..0000000000--- a/apps/web/lib/middleware/utils.ts+++ /dev/null@@ -1,68 +0,0 @@-import { SHORT_DOMAIN } from "@dub/utils";-import { NextRequest } from "next/server";--export const parse = (req: NextRequest) => {- let domain = req.headers.get("host") as string;- // remove www. from domain and convert to lowercase- domain = domain.replace("www.", "").toLowerCase();- if (domain === "dub.localhost:8888" || domain.endsWith(".vercel.app")) {- // for local development and preview URLs- domain = SHORT_DOMAIN;- }-- // path is the path of the URL (e.g. dub.co/stats/github -> /stats/github)- let path = req.nextUrl.pathname;-- // fullPath is the full URL path (along with search params)- const searchParams = req.nextUrl.searchParams.toString();- const fullPath = `${path}${- searchParams.length > 0 ? `?${searchParams}` : ""- }`;-- // Here, we are using decodeURIComponent to handle foreign languages like Hebrew- const key = decodeURIComponent(path.split("/")[1]); // key is the first part of the path (e.g. dub.co/stats/github -> stats)- const fullKey = decodeURIComponent(path.slice(1)); // fullKey is the full path without the first slash (to account for multi-level subpaths, e.g. d.to/github/repo -> github/repo)-- return { domain, path, fullPath, key, fullKey };-};--export const getFinalUrl = (url: string, { req }: { req: NextRequest }) => {- // query is the query string (e.g. d.to/github?utm_source=twitter -> ?utm_source=twitter)- const searchParams = req.nextUrl.searchParams;-- // get the query params of the target url- const urlObj = new URL(url);-- // if there are no query params, then return the target url as is (no need to parse it)- // @ts-ignore – until https://github.com/microsoft/TypeScript/issues/54466 is fixed- if (searchParams.size === 0) return url;-- // if searchParams (type: `URLSearchParams`) has the same key as target url, then overwrite it- for (const [key, value] of searchParams) {- urlObj.searchParams.set(key, value);- }-- // construct final url- const finalUrl = urlObj.toString();-- return finalUrl;-};--export const detectBot = (req: NextRequest) => {- const url = req.nextUrl;- if (url.searchParams.get("bot")) return true;- const ua = req.headers.get("User-Agent");- if (ua) {- /* Note:- * - bot is for most bots & crawlers- * - ChatGPT is for ChatGPT- * - facebookexternalhit is for Facebook crawler- * - WhatsApp is for WhatsApp crawler- * - MetaInspector is for https://metatags.io/- */- return /bot|chatgpt|facebookexternalhit|WhatsApp|google|baidu|bing|msn|duckduckbot|teoma|slurp|yandex|MetaInspector/i.test(- ua,- );- }- return false;-};diff --git a/apps/web/lib/middleware/utils/detect-bot.ts b/apps/web/lib/middleware/utils/detect-bot.tsnew file mode 100644index 0000000000..2fa191c16a--- /dev/null+++ b/apps/web/lib/middleware/utils/detect-bot.ts@@ -0,0 +1,20 @@+import { NextRequest } from "next/server";++export const detectBot = (req: NextRequest) => {+ const url = req.nextUrl;+ if (url.searchParams.get("bot")) return true;+ const ua = req.headers.get("User-Agent");+ if (ua) {+ /* Note:+ * - bot is for most bots & crawlers+ * - ChatGPT is for ChatGPT+ * - facebookexternalhit is for Facebook crawler+ * - WhatsApp is for WhatsApp crawler+ * - MetaInspector is for https://metatags.io/+ */+ return /bot|chatgpt|facebookexternalhit|WhatsApp|google|baidu|bing|msn|duckduckbot|teoma|slurp|yandex|MetaInspector/i.test(+ ua,+ );+ }+ return false;+};diff --git a/apps/web/lib/middleware/utils/detect-qr.ts b/apps/web/lib/middleware/utils/detect-qr.tsnew file mode 100644index 0000000000..b709982305--- /dev/null+++ b/apps/web/lib/middleware/utils/detect-qr.ts@@ -0,0 +1,7 @@+import { NextRequest } from "next/server";++export const detectQr = (req: NextRequest) => {+ const url = req.nextUrl;+ if (url.searchParams.get("qr") === "1") return true;+ return false;+};diff --git a/apps/web/lib/middleware/utils/get-final-url.ts b/apps/web/lib/middleware/utils/get-final-url.tsnew file mode 100644index 0000000000..5573f811e1--- /dev/null+++ b/apps/web/lib/middleware/utils/get-final-url.ts@@ -0,0 +1,28 @@+import { NextRequest } from "next/server";++export const getFinalUrl = (url: string, { req }: { req: NextRequest }) => {+ // query is the query string (e.g. d.to/github?utm_source=twitter -> ?utm_source=twitter)+ const searchParams = req.nextUrl.searchParams;++ // get the query params of the target url+ const urlObj = new URL(url);++ // if there are no query params, then return the target url as is (no need to parse it)+ // @ts-ignore – until https://github.com/microsoft/TypeScript/issues/54466 is fixed+ if (searchParams.size === 0) return url;++ // if searchParams (type: `URLSearchParams`) has the same key as target url, then overwrite it+ for (const [key, value] of searchParams) {+ urlObj.searchParams.set(key, value);+ }++ if (urlObj.searchParams.get("qr") === "1") {+ // remove qr param from the final url if the value is "1" (only used for detectQr function)+ urlObj.searchParams.delete("qr");+ }++ // construct final url+ const finalUrl = urlObj.toString();++ return finalUrl;+};diff --git a/apps/web/lib/edge.ts b/apps/web/lib/middleware/utils/get-identity-hash.tssimilarity index 100%rename from apps/web/lib/edge.tsrename to apps/web/lib/middleware/utils/get-identity-hash.tsdiff --git a/apps/web/lib/middleware/utils/index.ts b/apps/web/lib/middleware/utils/index.tsnew file mode 100644index 0000000000..407c04f109--- /dev/null+++ b/apps/web/lib/middleware/utils/index.ts@@ -0,0 +1,5 @@+export * from "./detect-bot";+export * from "./detect-qr";+export * from "./get-final-url";+export * from "./get-identity-hash";+export * from "./parse";diff --git a/apps/web/lib/middleware/utils/parse.ts b/apps/web/lib/middleware/utils/parse.tsnew file mode 100644index 0000000000..cc68b7f950--- /dev/null+++ b/apps/web/lib/middleware/utils/parse.ts@@ -0,0 +1,27 @@+import { SHORT_DOMAIN } from "@dub/utils";+import { NextRequest } from "next/server";++export const parse = (req: NextRequest) => {+ let domain = req.headers.get("host") as string;+ // remove www. from domain and convert to lowercase+ domain = domain.replace("www.", "").toLowerCase();+ if (domain === "dub.localhost:8888" || domain.endsWith(".vercel.app")) {+ // for local development and preview URLs+ domain = SHORT_DOMAIN;+ }++ // path is the path of the URL (e.g. dub.co/stats/github -> /stats/github)+ let path = req.nextUrl.pathname;++ // fullPath is the full URL path (along with search params)+ const searchParams = req.nextUrl.searchParams.toString();+ const fullPath = `${path}${+ searchParams.length > 0 ? `?${searchParams}` : ""+ }`;++ // Here, we are using decodeURIComponent to handle foreign languages like Hebrew+ const key = decodeURIComponent(path.split("/")[1]); // key is the first part of the path (e.g. dub.co/stats/github -> stats)+ const fullKey = decodeURIComponent(path.slice(1)); // fullKey is the full path without the first slash (to account for multi-level subpaths, e.g. d.to/github/repo -> github/repo)++ return { domain, path, fullPath, key, fullKey };+};diff --git a/apps/web/lib/openapi/analytics/browser.ts b/apps/web/lib/openapi/analytics/browser.tsindex 4fc45b9ce2..16762cb95b 100644--- a/apps/web/lib/openapi/analytics/browser.ts+++ b/apps/web/lib/openapi/analytics/browser.ts@@ -1,7 +1,8 @@import { openApiErrorResponses } from "@/lib/openapi/responses";import z from "@/lib/zod";-import { getAnalyticsQuerySchema } from "@/lib/zod/schemas/analytics";+import { getAnalyticsQuerySchema } from "@/lib/zod/schemas";import { ZodOpenApiOperationObject } from "zod-openapi";+import { workspaceParamsSchema } from "../request";export const getBrowserAnalytics: ZodOpenApiOperationObject = {operationId: "getBrowserAnalytics",@@ -10,13 +11,7 @@ export const getBrowserAnalytics: ZodOpenApiOperationObject = {description:"Retrieve the top browsers by number of clicks for a link, a domain, or the authenticated workspace.",requestParams: {- query: z- .object({- workspaceId: z- .string()- .describe("The ID of the workspace the link belongs to."),- })- .merge(getAnalyticsQuerySchema),+ query: workspaceParamsSchema.merge(getAnalyticsQuerySchema),},responses: {"200": {diff --git a/apps/web/lib/openapi/analytics/city.ts b/apps/web/lib/openapi/analytics/city.tsindex d93a58067e..3575c6272f 100644--- a/apps/web/lib/openapi/analytics/city.ts+++ b/apps/web/lib/openapi/analytics/city.ts@@ -1,8 +1,9 @@import { openApiErrorResponses } from "@/lib/openapi/responses";import z from "@/lib/zod";-import { getAnalyticsQuerySchema } from "@/lib/zod/schemas/analytics";+import { getAnalyticsQuerySchema } from "@/lib/zod/schemas";import { COUNTRY_CODES } from "@dub/utils";import { ZodOpenApiOperationObject } from "zod-openapi";+import { workspaceParamsSchema } from "../request";export const getCityAnalytics: ZodOpenApiOperationObject = {operationId: "getCityAnalytics",@@ -11,13 +12,7 @@ export const getCityAnalytics: ZodOpenApiOperationObject = {description:"Retrieve the top countries by number of clicks for a link, a domain, or the authenticated workspace.",requestParams: {- query: z- .object({- workspaceId: z- .string()- .describe("The ID of the workspace the link belongs to."),- })- .merge(getAnalyticsQuerySchema),+ query: workspaceParamsSchema.merge(getAnalyticsQuerySchema),},responses: {"200": {diff --git a/apps/web/lib/openapi/analytics/clicks.ts b/apps/web/lib/openapi/analytics/clicks.tsindex c00f6eaf84..59535146ae 100644--- a/apps/web/lib/openapi/analytics/clicks.ts+++ b/apps/web/lib/openapi/analytics/clicks.ts@@ -1,7 +1,7 @@import { openApiErrorResponses } from "@/lib/openapi/responses";-import z from "@/lib/zod";-import { getAnalyticsQuerySchema } from "@/lib/zod/schemas/analytics";+import { getAnalyticsQuerySchema } from "@/lib/zod/schemas";import { ZodOpenApiOperationObject } from "zod-openapi";+import { workspaceParamsSchema } from "../request";export const getClicksAnalytics: ZodOpenApiOperationObject = {operationId: "getClicksAnalytics",@@ -10,13 +10,7 @@ export const getClicksAnalytics: ZodOpenApiOperationObject = {description:"Retrieve the number of clicks for a link, a domain, or the authenticated workspace.",requestParams: {- query: z- .object({- workspaceId: z- .string()- .describe("The ID of the workspace the link belongs to."),- })- .merge(getAnalyticsQuerySchema),+ query: workspaceParamsSchema.merge(getAnalyticsQuerySchema),},responses: {"200": {diff --git a/apps/web/lib/openapi/analytics/country.ts b/apps/web/lib/openapi/analytics/country.tsindex 204afbb9c7..d466b46cb9 100644--- a/apps/web/lib/openapi/analytics/country.ts+++ b/apps/web/lib/openapi/analytics/country.ts@@ -1,8 +1,9 @@import { openApiErrorResponses } from "@/lib/openapi/responses";import z from "@/lib/zod";-import { getAnalyticsQuerySchema } from "@/lib/zod/schemas/analytics";+import { getAnalyticsQuerySchema } from "@/lib/zod/schemas";import { COUNTRY_CODES } from "@dub/utils";import { ZodOpenApiOperationObject } from "zod-openapi";+import { workspaceParamsSchema } from "../request";export const getCountryAnalytics: ZodOpenApiOperationObject = {operationId: "getCountryAnalytics",@@ -11,13 +12,7 @@ export const getCountryAnalytics: ZodOpenApiOperationObject = {description:"Retrieve the top countries by number of clicks for a link, a domain, or the authenticated workspace.",requestParams: {- query: z- .object({- workspaceId: z- .string()- .describe("The ID of the workspace the link belongs to."),- })- .merge(getAnalyticsQuerySchema),+ query: workspaceParamsSchema.merge(getAnalyticsQuerySchema),},responses: {"200": {diff --git a/apps/web/lib/openapi/analytics/device.ts b/apps/web/lib/openapi/analytics/device.tsindex 4520f26d95..185a788fa8 100644--- a/apps/web/lib/openapi/analytics/device.ts+++ b/apps/web/lib/openapi/analytics/device.ts@@ -1,7 +1,8 @@import { openApiErrorResponses } from "@/lib/openapi/responses";import z from "@/lib/zod";-import { getAnalyticsQuerySchema } from "@/lib/zod/schemas/analytics";+import { getAnalyticsQuerySchema } from "@/lib/zod/schemas";import { ZodOpenApiOperationObject } from "zod-openapi";+import { workspaceParamsSchema } from "../request";export const getDeviceAnalytics: ZodOpenApiOperationObject = {operationId: "getDeviceAnalytics",@@ -10,13 +11,7 @@ export const getDeviceAnalytics: ZodOpenApiOperationObject = {description:"Retrieve the top devices by number of clicks for a link, a domain, or the authenticated workspace.",requestParams: {- query: z- .object({- workspaceId: z- .string()- .describe("The ID of the workspace the link belongs to."),- })- .merge(getAnalyticsQuerySchema),+ query: workspaceParamsSchema.merge(getAnalyticsQuerySchema),},responses: {"200": {diff --git a/apps/web/lib/openapi/analytics/index.ts b/apps/web/lib/openapi/analytics/index.tsindex fa1b75d8eb..2f1a516701 100644--- a/apps/web/lib/openapi/analytics/index.ts+++ b/apps/web/lib/openapi/analytics/index.ts@@ -1,5 +1,4 @@import { ZodOpenApiPathsObject } from "zod-openapi";-import { getBrowserAnalytics } from "./browser";import { getCityAnalytics } from "./city";import { getClicksAnalytics } from "./clicks";diff --git a/apps/web/lib/openapi/analytics/os.ts b/apps/web/lib/openapi/analytics/os.tsindex a43f580d53..25b8f3e225 100644--- a/apps/web/lib/openapi/analytics/os.ts+++ b/apps/web/lib/openapi/analytics/os.ts@@ -1,7 +1,8 @@import { openApiErrorResponses } from "@/lib/openapi/responses";import z from "@/lib/zod";-import { getAnalyticsQuerySchema } from "@/lib/zod/schemas/analytics";+import { getAnalyticsQuerySchema } from "@/lib/zod/schemas";import { ZodOpenApiOperationObject } from "zod-openapi";+import { workspaceParamsSchema } from "../request";export const getOSAnalytics: ZodOpenApiOperationObject = {operationId: "getOSAnalytics",@@ -10,13 +11,7 @@ export const getOSAnalytics: ZodOpenApiOperationObject = {description:"Retrieve the top OS by number of clicks for a link, a domain, or the authenticated workspace.",requestParams: {- query: z- .object({- workspaceId: z- .string()- .describe("The ID of the workspace the link belongs to."),- })- .merge(getAnalyticsQuerySchema),+ query: workspaceParamsSchema.merge(getAnalyticsQuerySchema),},responses: {"200": {diff --git a/apps/web/lib/openapi/analytics/referer.ts b/apps/web/lib/openapi/analytics/referer.tsindex ede8700006..7cbde332f9 100644--- a/apps/web/lib/openapi/analytics/referer.ts+++ b/apps/web/lib/openapi/analytics/referer.ts@@ -1,7 +1,8 @@import { openApiErrorResponses } from "@/lib/openapi/responses";import z from "@/lib/zod";-import { getAnalyticsQuerySchema } from "@/lib/zod/schemas/analytics";+import { getAnalyticsQuerySchema } from "@/lib/zod/schemas";import { ZodOpenApiOperationObject } from "zod-openapi";+import { workspaceParamsSchema } from "../request";export const getRefererAnalytics: ZodOpenApiOperationObject = {operationId: "getRefererAnalytics",@@ -10,13 +11,7 @@ export const getRefererAnalytics: ZodOpenApiOperationObject = {description:"Retrieve the top referers by number of clicks for a link, a domain, or the authenticated workspace.",requestParams: {- query: z- .object({- workspaceId: z- .string()- .describe("The ID of the workspace the link belongs to."),- })- .merge(getAnalyticsQuerySchema),+ query: workspaceParamsSchema.merge(getAnalyticsQuerySchema),},responses: {"200": {diff --git a/apps/web/lib/openapi/analytics/timeseries.ts b/apps/web/lib/openapi/analytics/timeseries.tsindex 9ee4338d55..18c17fe500 100644--- a/apps/web/lib/openapi/analytics/timeseries.ts+++ b/apps/web/lib/openapi/analytics/timeseries.ts@@ -1,7 +1,8 @@import { openApiErrorResponses } from "@/lib/openapi/responses";import z from "@/lib/zod";-import { getAnalyticsQuerySchema } from "@/lib/zod/schemas/analytics";+import { getAnalyticsQuerySchema } from "@/lib/zod/schemas";import { ZodOpenApiOperationObject } from "zod-openapi";+import { workspaceParamsSchema } from "../request";export const getTimeseriesAnalytics: ZodOpenApiOperationObject = {operationId: "getTimeseriesAnalytics",@@ -10,13 +11,7 @@ export const getTimeseriesAnalytics: ZodOpenApiOperationObject = {description:"Retrieve the number of clicks for a link, a domain, or the authenticated workspace over a period of time.",requestParams: {- query: z- .object({- workspaceId: z- .string()- .describe("The ID of the workspace the link belongs to."),- })- .merge(getAnalyticsQuerySchema),+ query: workspaceParamsSchema.merge(getAnalyticsQuerySchema),},responses: {"200": {diff --git a/apps/web/lib/openapi/analytics/top-links.ts b/apps/web/lib/openapi/analytics/top-links.tsindex 6e8f8c21c5..586a1abc1d 100644--- a/apps/web/lib/openapi/analytics/top-links.ts+++ b/apps/web/lib/openapi/analytics/top-links.ts@@ -1,7 +1,8 @@import { openApiErrorResponses } from "@/lib/openapi/responses";import z from "@/lib/zod";-import { getAnalyticsQuerySchema } from "@/lib/zod/schemas/analytics";+import { getAnalyticsQuerySchema } from "@/lib/zod/schemas";import { ZodOpenApiOperationObject } from "zod-openapi";+import { workspaceParamsSchema } from "../request";export const getTopLinks: ZodOpenApiOperationObject = {operationId: "getTopLinks",@@ -10,13 +11,7 @@ export const getTopLinks: ZodOpenApiOperationObject = {description:"Retrieve the top links by number of clicks for a domain or the authenticated workspace.",requestParams: {- query: z- .object({- workspaceId: z- .string()- .describe("The ID of the workspace the link belongs to."),- })- .merge(getAnalyticsQuerySchema),+ query: workspaceParamsSchema.merge(getAnalyticsQuerySchema),},responses: {"200": {diff --git a/apps/web/lib/openapi/analytics/top-urls.ts b/apps/web/lib/openapi/analytics/top-urls.tsindex f81706fcd8..979c43f368 100644--- a/apps/web/lib/openapi/analytics/top-urls.ts+++ b/apps/web/lib/openapi/analytics/top-urls.ts@@ -1,7 +1,8 @@import { openApiErrorResponses } from "@/lib/openapi/responses";import z from "@/lib/zod";-import { getAnalyticsQuerySchema } from "@/lib/zod/schemas/analytics";+import { getAnalyticsQuerySchema } from "@/lib/zod/schemas";import { ZodOpenApiOperationObject } from "zod-openapi";+import { workspaceParamsSchema } from "../request";export const getTopURLs: ZodOpenApiOperationObject = {operationId: "getTopURLs",@@ -10,13 +11,7 @@ export const getTopURLs: ZodOpenApiOperationObject = {description:"Retrieve the top URLs by number of clicks for a given short link.",requestParams: {- query: z- .object({- workspaceId: z- .string()- .describe("The ID of the workspace the link belongs to."),- })- .merge(getAnalyticsQuerySchema),+ query: workspaceParamsSchema.merge(getAnalyticsQuerySchema),},responses: {"200": {diff --git a/apps/web/lib/openapi/index.ts b/apps/web/lib/openapi/index.tsindex 1fcbfa9c9b..c6d08980c3 100644--- a/apps/web/lib/openapi/index.ts+++ b/apps/web/lib/openapi/index.ts@@ -1,11 +1,10 @@import { openApiErrorResponses } from "@/lib/openapi/responses";-import { LinkSchema } from "@/lib/zod/schemas/links";-import { TagSchema } from "@/lib/zod/schemas/tags";-import { WorkspaceSchema } from "@/lib/zod/schemas/workspaces";+import { LinkSchema, TagSchema, WorkspaceSchema } from "@/lib/zod/schemas";import { API_DOMAIN } from "@dub/utils";import { ZodOpenApiObject } from "zod-openapi";import { analyticsPaths } from "./analytics";import { linksPaths } from "./links";+import { metatagsPath } from "./metatags";import { qrCodePaths } from "./qr";import { tagsPaths } from "./tags";import { workspacesPaths } from "./workspaces";@@ -39,6 +38,7 @@ export const openApiObject: ZodOpenApiObject = {...analyticsPaths,...workspacesPaths,...tagsPaths,+ ...metatagsPath,},components: {schemas: {diff --git a/apps/web/lib/openapi/links/create-bulk-link.ts b/apps/web/lib/openapi/links/create-bulk-link.tsindex d4346b44fa..3d0bb71dcd 100644--- a/apps/web/lib/openapi/links/create-bulk-link.ts+++ b/apps/web/lib/openapi/links/create-bulk-link.ts@@ -1,8 +1,8 @@-import { ZodOpenApiOperationObject } from "zod-openapi";-import { openApiErrorResponses } from "@/lib/openapi/responses";import z from "@/lib/zod";-import { LinkSchema, createLinkBodySchema } from "@/lib/zod/schemas/links";+import { LinkSchema, createLinkBodySchema } from "@/lib/zod/schemas";+import { ZodOpenApiOperationObject } from "zod-openapi";+import { workspaceParamsSchema } from "../request";export const createBulkLink: ZodOpenApiOperationObject = {operationId: "bulkCreateLinks",@@ -10,11 +10,7 @@ export const createBulkLink: ZodOpenApiOperationObject = {summary: "Bulk create links",description: "Bulk create up to 100 links for the authenticated workspace.",requestParams: {- query: z.object({- workspaceId: z- .string()- .describe("The ID of the workspace to create the link for."),- }),+ query: workspaceParamsSchema,},requestBody: {content: {diff --git a/apps/web/lib/openapi/links/create-link.ts b/apps/web/lib/openapi/links/create-link.tsindex 0c18cb761f..008ff1cf39 100644--- a/apps/web/lib/openapi/links/create-link.ts+++ b/apps/web/lib/openapi/links/create-link.ts@@ -1,7 +1,7 @@import { openApiErrorResponses } from "@/lib/openapi/responses";-import z from "@/lib/zod";-import { LinkSchema, createLinkBodySchema } from "@/lib/zod/schemas/links";+import { LinkSchema, createLinkBodySchema } from "@/lib/zod/schemas";import { ZodOpenApiOperationObject } from "zod-openapi";+import { workspaceParamsSchema } from "../request";export const createLink: ZodOpenApiOperationObject = {operationId: "createLink",@@ -9,11 +9,7 @@ export const createLink: ZodOpenApiOperationObject = {summary: "Create a new link",description: "Create a new link for the authenticated workspace.",requestParams: {- query: z.object({- workspaceId: z- .string()- .describe("The ID of the workspace to create the link for."),- }),+ query: workspaceParamsSchema,},requestBody: {content: {diff --git a/apps/web/lib/openapi/links/delete-link.ts b/apps/web/lib/openapi/links/delete-link.tsindex 32927774ef..c48145f6d1 100644--- a/apps/web/lib/openapi/links/delete-link.ts+++ b/apps/web/lib/openapi/links/delete-link.ts@@ -1,7 +1,7 @@-import { ZodOpenApiOperationObject } from "zod-openapi";-import { openApiErrorResponses } from "@/lib/openapi/responses";import z from "@/lib/zod";+import { ZodOpenApiOperationObject } from "zod-openapi";+import { workspaceParamsSchema } from "../request";export const deleteLink: ZodOpenApiOperationObject = {operationId: "deleteLink",@@ -10,11 +10,7 @@ export const deleteLink: ZodOpenApiOperationObject = {summary: "Delete a link",description: "Delete a link for the authenticated workspace.",requestParams: {- query: z.object({- workspaceId: z- .string()- .describe("The ID of the workspace the link belongs to."),- }),+ query: workspaceParamsSchema,path: z.object({linkId: z.string().openapi({description:diff --git a/apps/web/lib/openapi/links/edit-link.ts b/apps/web/lib/openapi/links/edit-link.tsindex 353fd51ffb..2f2234c78f 100644--- a/apps/web/lib/openapi/links/edit-link.ts+++ b/apps/web/lib/openapi/links/edit-link.ts@@ -1,8 +1,8 @@-import { ZodOpenApiOperationObject } from "zod-openapi";-import { openApiErrorResponses } from "@/lib/openapi/responses";import z from "@/lib/zod";-import { LinkSchema, createLinkBodySchema } from "@/lib/zod/schemas/links";+import { LinkSchema, createLinkBodySchema } from "@/lib/zod/schemas";+import { ZodOpenApiOperationObject } from "zod-openapi";+import { workspaceParamsSchema } from "../request";export const editLink: ZodOpenApiOperationObject = {operationId: "editLink",@@ -11,11 +11,7 @@ export const editLink: ZodOpenApiOperationObject = {summary: "Edit a link",description: "Edit a link for the authenticated workspace.",requestParams: {- query: z.object({- workspaceId: z- .string()- .describe("The ID of the workspace the link belongs to."),- }),+ query: workspaceParamsSchema,path: z.object({linkId: z.string().openapi({description:diff --git a/apps/web/lib/openapi/links/get-link-info.ts b/apps/web/lib/openapi/links/get-link-info.tsindex 1d6196de9f..00f8788aab 100644--- a/apps/web/lib/openapi/links/get-link-info.ts+++ b/apps/web/lib/openapi/links/get-link-info.ts@@ -1,8 +1,7 @@-import { ZodOpenApiOperationObject } from "zod-openapi";-import { openApiErrorResponses } from "@/lib/openapi/responses";-import z from "@/lib/zod";-import { getLinkInfoQuerySchema, LinkSchema } from "@/lib/zod/schemas/links";+import { domainKeySchema, LinkSchema } from "@/lib/zod/schemas";+import { ZodOpenApiOperationObject } from "zod-openapi";+import { workspaceParamsSchema } from "../request";export const getLinkInfo: ZodOpenApiOperationObject = {operationId: "getLinkInfo",@@ -10,13 +9,7 @@ export const getLinkInfo: ZodOpenApiOperationObject = {summary: "Retrieve a link",description: "Retrieve the info for a link from their domain and key.",requestParams: {- query: z- .object({- workspaceId: z- .string()- .describe("The ID of the workspace the link belongs to."),- })- .merge(getLinkInfoQuerySchema),+ query: workspaceParamsSchema.merge(domainKeySchema),},responses: {"200": {diff --git a/apps/web/lib/openapi/links/get-links-count.ts b/apps/web/lib/openapi/links/get-links-count.tsindex ac1d3a5376..9cdb8ca062 100644--- a/apps/web/lib/openapi/links/get-links-count.ts+++ b/apps/web/lib/openapi/links/get-links-count.ts@@ -1,7 +1,8 @@import { openApiErrorResponses } from "@/lib/openapi/responses";import z from "@/lib/zod";-import { getLinksCountQuerySchema } from "@/lib/zod/schemas/links";+import { getLinksCountQuerySchema } from "@/lib/zod/schemas";import { ZodOpenApiOperationObject } from "zod-openapi";+import { workspaceParamsSchema } from "../request";export const getLinksCount: ZodOpenApiOperationObject = {operationId: "getLinksCount",@@ -10,13 +11,7 @@ export const getLinksCount: ZodOpenApiOperationObject = {description:"Retrieve the number of links for the authenticated workspace. The provided query parameters allow filtering the returned links.",requestParams: {- query: z- .object({- workspaceId: z- .string()- .describe("The ID of the workspace the link belongs to."),- })- .merge(getLinksCountQuerySchema),+ query: workspaceParamsSchema.merge(getLinksCountQuerySchema),},responses: {"200": {diff --git a/apps/web/lib/openapi/links/get-links.ts b/apps/web/lib/openapi/links/get-links.tsindex ce36582050..bc1614dc4d 100644--- a/apps/web/lib/openapi/links/get-links.ts+++ b/apps/web/lib/openapi/links/get-links.ts@@ -1,7 +1,8 @@import { openApiErrorResponses } from "@/lib/openapi/responses";import z from "@/lib/zod";-import { getLinksQuerySchema, LinkSchema } from "@/lib/zod/schemas/links";+import { getLinksQuerySchema, LinkSchema } from "@/lib/zod/schemas";import { ZodOpenApiOperationObject } from "zod-openapi";+import { workspaceParamsSchema } from "../request";export const getLinks: ZodOpenApiOperationObject = {operationId: "getLinks",@@ -10,13 +11,7 @@ export const getLinks: ZodOpenApiOperationObject = {description:"Retrieve a list of links for the authenticated workspace. The list will be paginated and the provided query parameters allow filtering the returned links.",requestParams: {- query: z- .object({- workspaceId: z- .string()- .describe("The ID of the workspace the link belongs to."),- })- .merge(getLinksQuerySchema),+ query: workspaceParamsSchema.merge(getLinksQuerySchema),},responses: {"200": {diff --git a/apps/web/lib/openapi/metatags/index.ts b/apps/web/lib/openapi/metatags/index.tsnew file mode 100644index 0000000000..bab1da443d--- /dev/null+++ b/apps/web/lib/openapi/metatags/index.ts@@ -0,0 +1,45 @@+import { getUrlQuerySchema } from "@/lib/zod/schemas";+import { ZodOpenApiOperationObject, ZodOpenApiPathsObject } from "zod-openapi";++const getMetatags: ZodOpenApiOperationObject = {+ operationId: "getMetatags",+ "x-speakeasy-name-override": "get",+ summary: "Retrieve the metatags for a URL",+ description: "Retrieve the metatags for a URL",+ requestParams: {+ query: getUrlQuerySchema,+ },+ responses: {+ "200": {+ description: "The retrieved metatags",+ content: {+ "application/json": {+ schema: {+ type: "object",+ properties: {+ title: {+ type: "string",+ description: "The meta title tag for the URL",+ },+ description: {+ type: "string",+ description: "The meta description tag for the URL",+ },+ image: {+ type: "string",+ description: "The OpenGraph image for the URL",+ },+ },+ },+ },+ },+ },+ },+ tags: ["Metatags"],+};++export const metatagsPath: ZodOpenApiPathsObject = {+ "/metatags": {+ get: getMetatags,+ },+};diff --git a/apps/web/lib/openapi/qr/get-qr.ts b/apps/web/lib/openapi/qr/get-qr.tsindex 59daf1c542..0c8d2d5d83 100644--- a/apps/web/lib/openapi/qr/get-qr.ts+++ b/apps/web/lib/openapi/qr/get-qr.ts@@ -1,6 +1,6 @@import { openApiErrorResponses } from "@/lib/openapi/responses";import z from "@/lib/zod";-import { getQRCodeQuerySchema } from "@/lib/zod/schemas/qr";+import { getQRCodeQuerySchema } from "@/lib/zod/schemas";import { ZodOpenApiOperationObject } from "zod-openapi";export const getQRCode: ZodOpenApiOperationObject = {diff --git a/apps/web/lib/openapi/request.ts b/apps/web/lib/openapi/request.tsnew file mode 100644index 0000000000..30ad4093af--- /dev/null+++ b/apps/web/lib/openapi/request.ts@@ -0,0 +1,12 @@+import z from "../zod";++export const workspaceParamsSchema = z.object({+ workspaceId: z.string().describe("The ID of the workspace."),+ projectSlug: z+ .string()+ .optional()+ .describe(+ "The slug of the project. This field is deprecated – use `workspaceId` instead.",+ )+ .openapi({ deprecated: true }),+});diff --git a/apps/web/lib/openapi/tags/create-tag.ts b/apps/web/lib/openapi/tags/create-tag.tsindex 8d51787ea3..29d7dffcc6 100644--- a/apps/web/lib/openapi/tags/create-tag.ts+++ b/apps/web/lib/openapi/tags/create-tag.ts@@ -1,8 +1,7 @@-import { ZodOpenApiOperationObject } from "zod-openapi";-import { openApiErrorResponses } from "@/lib/openapi/responses";-import z from "@/lib/zod";-import { createTagBodySchema, TagSchema } from "@/lib/zod/schemas/tags";+import { createTagBodySchema, TagSchema } from "@/lib/zod/schemas";+import { ZodOpenApiOperationObject } from "zod-openapi";+import { workspaceParamsSchema } from "../request";export const createTag: ZodOpenApiOperationObject = {operationId: "createTag",@@ -10,11 +9,7 @@ export const createTag: ZodOpenApiOperationObject = {summary: "Create a new tag",description: "Create a new tag for the authenticated workspace.",requestParams: {- query: z.object({- workspaceId: z- .string()- .describe("The ID of the workspace to create the tag for."),- }),+ query: workspaceParamsSchema,},requestBody: {content: {diff --git a/apps/web/lib/openapi/tags/get-tags.ts b/apps/web/lib/openapi/tags/get-tags.tsindex 4b644f10ae..6b7072f312 100644--- a/apps/web/lib/openapi/tags/get-tags.ts+++ b/apps/web/lib/openapi/tags/get-tags.ts@@ -1,8 +1,8 @@-import { ZodOpenApiOperationObject } from "zod-openapi";-import { openApiErrorResponses } from "@/lib/openapi/responses";import z from "@/lib/zod";-import { TagSchema } from "@/lib/zod/schemas/tags";+import { TagSchema } from "@/lib/zod/schemas";+import { ZodOpenApiOperationObject } from "zod-openapi";+import { workspaceParamsSchema } from "../request";export const getTags: ZodOpenApiOperationObject = {operationId: "getTags",@@ -10,11 +10,7 @@ export const getTags: ZodOpenApiOperationObject = {summary: "Retrieve a list of tags",description: "Retrieve a list of tags for the authenticated workspace.",requestParams: {- query: z.object({- workspaceId: z- .string()- .describe("The ID of the workspace to retrieve the tags for."),- }),+ query: workspaceParamsSchema,},responses: {"200": {diff --git a/apps/web/lib/openapi/workspaces/create-workspace.ts b/apps/web/lib/openapi/workspaces/create-workspace.tsindex 085a1fa2b7..a02af6d693 100644--- a/apps/web/lib/openapi/workspaces/create-workspace.ts+++ b/apps/web/lib/openapi/workspaces/create-workspace.ts@@ -1,8 +1,5 @@import { openApiErrorResponses } from "@/lib/openapi/responses";-import {- WorkspaceSchema,- createWorkspaceSchema,-} from "@/lib/zod/schemas/workspaces";+import { WorkspaceSchema, createWorkspaceSchema } from "@/lib/zod/schemas";export const createWorkspace = {operationId: "createWorkspace",diff --git a/apps/web/lib/openapi/workspaces/get-workspace-info.ts b/apps/web/lib/openapi/workspaces/get-workspace-info.tsindex c599a533df..f68b750e3c 100644--- a/apps/web/lib/openapi/workspaces/get-workspace-info.ts+++ b/apps/web/lib/openapi/workspaces/get-workspace-info.ts@@ -1,8 +1,7 @@-import { ZodOpenApiOperationObject } from "zod-openapi";-import { openApiErrorResponses } from "@/lib/openapi/responses";import z from "@/lib/zod";-import { WorkspaceSchema } from "@/lib/zod/schemas/workspaces";+import { WorkspaceSchema } from "@/lib/zod/schemas";+import { ZodOpenApiOperationObject } from "zod-openapi";export const getWorkspaceInfo: ZodOpenApiOperationObject = {operationId: "getWorkspace",diff --git a/apps/web/lib/openapi/workspaces/get-workspaces.ts b/apps/web/lib/openapi/workspaces/get-workspaces.tsindex ca43f58b7e..00d1434e3f 100644--- a/apps/web/lib/openapi/workspaces/get-workspaces.ts+++ b/apps/web/lib/openapi/workspaces/get-workspaces.ts@@ -1,8 +1,7 @@-import { ZodOpenApiOperationObject } from "zod-openapi";-import { openApiErrorResponses } from "@/lib/openapi/responses";import z from "@/lib/zod";-import { WorkspaceSchema } from "@/lib/zod/schemas/workspaces";+import { WorkspaceSchema } from "@/lib/zod/schemas";+import { ZodOpenApiOperationObject } from "zod-openapi";export const getWorkspaces: ZodOpenApiOperationObject = {operationId: "getWorkspaces",diff --git a/apps/web/lib/planetscale.ts b/apps/web/lib/planetscale.tsindex b71c42f291..a1e70bcad9 100644--- a/apps/web/lib/planetscale.ts+++ b/apps/web/lib/planetscale.ts@@ -1,4 +1,4 @@-import { nanoid } from "@dub/utils";+import { nanoid, punyEncode } from "@dub/utils";import { connect } from "@planetscale/database";import { DomainProps, WorkspaceProps } from "./types";@@ -50,7 +50,7 @@ export const checkIfKeyExists = async (domain: string, key: string) => {const { rows } =(await conn.execute("SELECT 1 FROM Link WHERE domain = ? AND `key` = ? LIMIT 1",- [domain, decodeURIComponent(key)], // we need to make sure that the key is always decoded (cause that's how we store it in MySQL)+ [domain, punyEncode(decodeURIComponent(key))], // we need to make sure that the key is always URI-decoded + punycode-encoded (cause that's how we store it in MySQL))) || {};return rows && Array.isArray(rows) && rows.length > 0;@@ -62,7 +62,7 @@ export const getLinkViaEdge = async (domain: string, key: string) => {const { rows } =(await conn.execute("SELECT * FROM Link WHERE domain = ? AND `key` = ?",- [domain, decodeURIComponent(key)], // we need to make sure that the key is always decoded (cause that's how we store it in MySQL)+ [domain, punyEncode(decodeURIComponent(key))], // we need to make sure that the key is always URI-decoded + punycode-encoded (cause that's how we store it in MySQL))) || {};return rows && Array.isArray(rows) && rows.length > 0diff --git a/apps/web/lib/swr/use-domains.ts b/apps/web/lib/swr/use-domains.tsindex 17a51a54c6..596bd652c1 100644--- a/apps/web/lib/swr/use-domains.ts+++ b/apps/web/lib/swr/use-domains.ts@@ -49,8 +49,10 @@ export default function useDomains({];const primaryDomain =- activeWorkspaceDomains?.find((domain) => domain.primary)?.slug ||- SHORT_DOMAIN;+ activeWorkspaceDomains && activeWorkspaceDomains.length > 0+ ? activeWorkspaceDomains.find((domain) => domain.primary)?.slug ||+ activeWorkspaceDomains[0].slug+ : SHORT_DOMAIN;const verified = domain? // If a domain is passed, check if it's verifieddiff --git a/apps/web/lib/tinybird.ts b/apps/web/lib/tinybird.tsindex bc4cc51587..7f6233228f 100644--- a/apps/web/lib/tinybird.ts+++ b/apps/web/lib/tinybird.ts@@ -8,8 +8,7 @@ import {} from "@dub/utils";import { ipAddress } from "@vercel/edge";import { NextRequest, userAgent } from "next/server";-import { getIdentityHash } from "./edge";-import { detectBot } from "./middleware/utils";+import { detectBot, detectQr, getIdentityHash } from "./middleware/utils";import { conn } from "./planetscale";import { LinkProps } from "./types";import { ratelimit } from "./upstash";@@ -30,17 +29,18 @@ export async function recordClick({}) {const isBot = detectBot(req);if (isBot) {- return null;+ return null; // don't record clicks from bots}+ const isQr = detectQr(req);const geo = process.env.VERCEL === "1" ? req.geo : LOCALHOST_GEO_DATA;const ua = userAgent(req);const referer = req.headers.get("referer");const ip = process.env.VERCEL === "1" ? ipAddress(req) : LOCALHOST_IP;const identity_hash = await getIdentityHash(req);- // if in production / preview env, deduplicate clicks from the same IP & link ID – only record 1 click per hour+ // if in production / preview env, deduplicate clicks from the same IP address + link ID – only record 1 click per hourif (process.env.VERCEL === "1") {const { success } = await ratelimit(2, "1 h").limit(- `recordClick:${identity_hash}:${id}`,+ `recordClick:${ip}:${id}`,);if (!success) {return null;@@ -87,6 +87,7 @@ export async function recordClick({cpu_architecture: ua.cpu?.architecture || "Unknown",ua: ua.ua || "Unknown",bot: ua.isBot,+ qr: isQr,referer: referer? getDomainWithoutWWW(referer) || "(direct)": "(direct)",diff --git a/apps/web/lib/zod/index.ts b/apps/web/lib/zod/index.tsindex 66105b0c43..f56a446fa6 100644--- a/apps/web/lib/zod/index.ts+++ b/apps/web/lib/zod/index.ts@@ -1,4 +1,3 @@-import { validDomainRegex } from "@dub/utils";import * as z from "zod";import { extendZodWithOpenApi } from "zod-openapi";@@ -6,13 +5,6 @@ extendZodWithOpenApi(z);export default z;-export const domainKeySchema = z.object({- domain: z.string().refine((v) => validDomainRegex.test(v), {- message: "Invalid domain format",- }),- key: z.string().min(1),-});-export const workspaceIdSchema = z.object({workspaceId: z.string()diff --git a/apps/web/lib/zod/schemas/analytics.ts b/apps/web/lib/zod/schemas/analytics.tsindex cd2a1f2061..693aff8101 100644--- a/apps/web/lib/zod/schemas/analytics.ts+++ b/apps/web/lib/zod/schemas/analytics.ts@@ -1,7 +1,7 @@import { intervals, VALID_TINYBIRD_ENDPOINTS } from "@/lib/analytics";import z from "@/lib/zod";import { COUNTRY_CODES } from "@dub/utils";-import { booleanQuerySchema } from ".";+import { booleanQuerySchema } from "./misc";export const getAnalyticsQuerySchema = z.object({domain: z.string().optional().describe("The domain of the short link."),diff --git a/apps/web/lib/zod/schemas/index.ts b/apps/web/lib/zod/schemas/index.tsindex c203f53c71..f8656b3fa0 100644--- a/apps/web/lib/zod/schemas/index.ts+++ b/apps/web/lib/zod/schemas/index.ts@@ -1,16 +1,6 @@-import { plans, roles } from "@/lib/types";-import z from "@/lib/zod";--export const planSchema = z.enum(plans).describe("The plan of the workspace.");--export const roleSchema = z- .enum(roles)- .describe("The role of the authenticated user in the workspace.");--// A boolean query schema that coerces the value to a boolean-export const booleanQuerySchema = z- .enum(["true", "false"])- .transform((value) => value == "true")- .openapi({- type: "boolean",- });+export * from "./analytics";+export * from "./links";+export * from "./misc";+export * from "./qr";+export * from "./tags";+export * from "./workspaces";diff --git a/apps/web/lib/zod/schemas/links.ts b/apps/web/lib/zod/schemas/links.tsindex 250ed3440f..0f86edb48c 100644--- a/apps/web/lib/zod/schemas/links.ts+++ b/apps/web/lib/zod/schemas/links.ts@@ -1,14 +1,21 @@import z from "@/lib/zod";-import { getUrlFromString, isValidUrl, validDomainRegex } from "@dub/utils";-import { booleanQuerySchema } from ".";+import {+ COUNTRY_CODES,+ getUrlFromString,+ isValidUrl,+ validDomainRegex,+} from "@dub/utils";+import { booleanQuerySchema } from "./misc";import { TagSchema } from "./tags";+export const parseUrlSchema = z+ .string()+ .describe("The destination URL of the short link.")+ .transform((v) => getUrlFromString(v))+ .refine((v) => isValidUrl(v), { message: "Invalid URL" });+export const getUrlQuerySchema = z.object({- url: z- .string()- .describe("The destination URL of the short link.")- .transform((v) => getUrlFromString(v))- .refine((v) => isValidUrl(v), { message: "Invalid URL" }),+ url: parseUrlSchema,});export const getDomainQuerySchema = z.object({@@ -29,7 +36,7 @@ const LinksQuerySchema = z.object({.string().optional().describe(- "[DEPRECATED] (use tagIds instead): The tag ID to filter the links by.",+ "The tag ID to filter the links by. This field is deprecated – use `tagIds` instead.",).openapi({ deprecated: true }),tagIds: z@@ -85,13 +92,16 @@ export const getLinksCountQuerySchema = LinksQuerySchema.merge(}),);-export const getLinkInfoQuerySchema = z.object({+export const domainKeySchema = z.object({domain: z.string().min(1, "Domain is required.").describe("The domain of the link to retrieve. E.g. for `d.to/github`, the domain is `d.to`.",- ),+ )+ .refine((v) => validDomainRegex.test(v), {+ message: "Invalid domain format",+ }),key: z.string().min(1, "Key is required.")@@ -119,18 +129,35 @@ export const createLinkBodySchema = z.object({.describe("The prefix of the short link slug for randomly-generated keys (e.g. if prefix is `/c/`, generated keys will be in the `/c/:key` format). Will be ignored if `key` is provided.",),- url: z.string().describe("The destination URL of the short link."),+ url: parseUrlSchema.describe("The destination URL of the short link."),archived: z.boolean().optional().default(false).describe("Whether the short link is archived."),+ publicStats: z+ .boolean()+ .optional()+ .default(false)+ .describe("Whether the short link's stats are publicly accessible."),+ tagId: z+ .string()+ .nullish()+ .describe(+ "The unique ID of the tag assigned to the short link. This field is deprecated – use `tagIds` instead.",+ )+ .openapi({ deprecated: true }),+ tagIds: z+ .union([z.string(), z.array(z.string())])+ .transform((v) => (Array.isArray(v) ? v : v.split(",")))+ .optional()+ .describe("The unique IDs of the tags assigned to the short link."),+ comments: z.string().nullish().describe("The comments for the short link."),expiresAt: z.string().nullish().describe("The date and time when the short link will expire at."),- expiredUrl: z- .string()+ expiredUrl: parseUrlSchema.nullish().describe("The URL to redirect to when the short link has expired."),password: z@@ -167,42 +194,22 @@ export const createLinkBodySchema = z.object({.optional().default(false).describe("Whether the short link uses link cloaking."),- ios: z- .string()+ ios: parseUrlSchema.nullish().describe("The iOS destination URL for the short link for iOS device targeting.",),- android: z- .string()+ android: parseUrlSchema.nullish().describe("The Android destination URL for the short link for Android device targeting.",),geo: z- .record(z.string())+ .record(z.enum(COUNTRY_CODES), parseUrlSchema).nullish().describe("Geo targeting information for the short link in JSON format `{[COUNTRY]: https://example.com }`.",),- publicStats: z- .boolean()- .optional()- .default(false)- .describe("Whether the short link's stats are publicly accessible."),- tagId: z- .string()- .nullish()- .describe(- "[DEPRECATED] (use tagIds instead): The unique ID of the tag assigned to the short link.",- )- .openapi({ deprecated: true }),- tagIds: z- .union([z.string(), z.array(z.string())])- .transform((v) => (Array.isArray(v) ? v : v.split(",")))- .optional()- .describe("The unique IDs of the tags assigned to the short link."),- comments: z.string().nullish().describe("The comments for the short link."),});export const updateLinkBodySchema = createLinkBodySchema.partial();@@ -289,7 +296,7 @@ export const LinkSchema = z"The Android destination URL for the short link for Android device targeting.",),geo: z- .record(z.string())+ .record(z.enum(COUNTRY_CODES), z.string().url()).nullable().describe("Geo targeting information for the short link in JSON format `{[COUNTRY]: https://example.com }`. Learn more: https://d.to/geo",@@ -302,7 +309,7 @@ export const LinkSchema = z.string().nullable().describe(- "[DEPRECATED] (use `tags` instead): The unique ID of the tag assigned to the short link.",+ "The unique ID of the tag assigned to the short link. This field is deprecated – use `tags` instead.",).openapi({ deprecated: true }),tags: TagSchema.array()@@ -362,7 +369,7 @@ export const LinkSchema = zprojectId: z.string().describe(- "[DEPRECATED] (use workspaceId instead): The project ID of the short link.",+ "The project ID of the short link. This field is deprecated – use `workspaceId` instead.",).openapi({ deprecated: true }),})diff --git a/apps/web/lib/zod/schemas/misc.ts b/apps/web/lib/zod/schemas/misc.tsnew file mode 100644index 0000000000..c203f53c71--- /dev/null+++ b/apps/web/lib/zod/schemas/misc.ts@@ -0,0 +1,16 @@+import { plans, roles } from "@/lib/types";+import z from "@/lib/zod";++export const planSchema = z.enum(plans).describe("The plan of the workspace.");++export const roleSchema = z+ .enum(roles)+ .describe("The role of the authenticated user in the workspace.");++// A boolean query schema that coerces the value to a boolean+export const booleanQuerySchema = z+ .enum(["true", "false"])+ .transform((value) => value == "true")+ .openapi({+ type: "boolean",+ });diff --git a/apps/web/lib/zod/schemas/qr.ts b/apps/web/lib/zod/schemas/qr.tsindex fc1353d1bc..a722177f78 100644--- a/apps/web/lib/zod/schemas/qr.ts+++ b/apps/web/lib/zod/schemas/qr.ts@@ -5,7 +5,7 @@ import {QR_LEVELS,} from "@/lib/qr/constants";import z from "@/lib/zod";-import { booleanQuerySchema } from ".";+import { booleanQuerySchema } from "./misc";export const getQRCodeQuerySchema = z.object({url: zdiff --git a/apps/web/package.json b/apps/web/package.jsonindex a73945b414..817d02fc7e 100644--- a/apps/web/package.json+++ b/apps/web/package.json@@ -59,9 +59,9 @@"js-cookie": "^3.0.5","json-2-csv": "^5.5.0","jszip": "^3.10.1",- "lucide-react": "^0.299.0",+ "lucide-react": "^0.367.0","nanoid": "^5.0.1",- "next": "14.2.0-canary.47",+ "next": "14.2.0-canary.67","next-auth": "^4.24.4","node-html-parser": "^6.1.4","nodemailer": "^6.9.3",@@ -70,7 +70,6 @@"openapi3-ts": "^4.2.1","postmark": "^4.0.2","prisma": "^5.9.1",- "punycode": "^2.3.0","react": "^18.2.0","react-colorful": "^5.6.1","react-dom": "^18.2.0",diff --git a/apps/web/scripts/bulk-create-domains.ts b/apps/web/scripts/bulk-create-domains.tsindex 99fdb22f85..2c80369f76 100644--- a/apps/web/scripts/bulk-create-domains.ts+++ b/apps/web/scripts/bulk-create-domains.ts@@ -1,8 +1,8 @@import { addDomainToVercel, setRootDomain } from "@/lib/api/domains";+import prisma from "@/lib/prisma";import "dotenv-flow/config";import * as fs from "fs";import * as Papa from "papaparse";-import prisma from "@/lib/prisma";const projectId = "xxx";const domains: { domain: string; target: string }[] = [];diff --git a/apps/web/ui/analytics/feedback/action.ts b/apps/web/ui/analytics/feedback/action.tsindex fcf46ba1f8..d4e4f44361 100644--- a/apps/web/ui/analytics/feedback/action.ts+++ b/apps/web/ui/analytics/feedback/action.ts@@ -10,7 +10,7 @@ export async function submitFeedback(data: FormData) {const emailHtml = render(FeedbackEmail({ email, feedback }));- return await client.sendEmail({+ return await client?.sendEmail({From: "[email protected]",To: "[email protected]",...(email && { ReplyTo: email }),diff --git a/apps/web/ui/analytics/link-preview.tsx b/apps/web/ui/analytics/link-preview.tsxindex 2c35eaea8f..9b456a2641 100644--- a/apps/web/ui/analytics/link-preview.tsx+++ b/apps/web/ui/analytics/link-preview.tsx@@ -9,7 +9,6 @@ import {truncate,} from "@dub/utils";import { Archive, EyeOff, Globe } from "lucide-react";-import punycode from "punycode/";export default function LinkPreviewTooltip({data,@@ -59,7 +58,7 @@ export default function LinkPreviewTooltip({>{truncate(linkConstructor({- domain: punycode.toUnicode(data.domain || ""),+ domain: data.domain,key: data.key,pretty: true,}),diff --git a/apps/web/ui/analytics/toggle.tsx b/apps/web/ui/analytics/toggle.tsxindex 5994987f64..6edcb29a07 100644--- a/apps/web/ui/analytics/toggle.tsx+++ b/apps/web/ui/analytics/toggle.tsx@@ -6,7 +6,6 @@ import {getApexDomain,linkConstructor,} from "@dub/utils";-import punycode from "punycode/";import { useContext } from "react";import { AnalyticsContext } from ".";import DateRangePicker from "./date-range-picker";@@ -64,7 +63,7 @@ export default function Toggle() {/><p className="max-w-[192px] truncate sm:max-w-[400px]">{linkConstructor({- domain: punycode.toUnicode(domain),+ domain,key,pretty: true,})}diff --git a/apps/web/ui/domains/domain-card.tsx b/apps/web/ui/domains/domain-card.tsxindex 8c5a1e3ec5..5b11add210 100644--- a/apps/web/ui/domains/domain-card.tsx+++ b/apps/web/ui/domains/domain-card.tsx@@ -19,10 +19,15 @@ import {SimpleTooltipContent,useIntersectionObserver,} from "@dub/ui";-import { capitalize, fetcher, nFormatter, truncate } from "@dub/utils";+import {+ capitalize,+ fetcher,+ nFormatter,+ punycode,+ truncate,+} from "@dub/utils";import { Archive, Edit3, FileCog, FolderInput, QrCode } from "lucide-react";import Link from "next/link";-import punycode from "punycode/";import { useRef, useState } from "react";import useSWR, { mutate } from "swr";import { useAddEditDomainModal } from "../modals/add-edit-domain-modal";@@ -128,7 +133,7 @@ export default function DomainCard({ props }: { props: DomainProps }) {className="flex items-center space-x-2"><p className="flex items-center text-xl font-semibold">- {punycode.toUnicode(domain)}+ {punycode(domain)}</p><ExternalLink className="h-5 w-5" /></a>diff --git a/apps/web/ui/links/link-card.tsx b/apps/web/ui/links/link-card.tsxindex 97e15e3aec..ec3d316f10 100644--- a/apps/web/ui/links/link-card.tsx+++ b/apps/web/ui/links/link-card.tsx@@ -29,6 +29,7 @@ import {isDubDomain,linkConstructor,nFormatter,+ punycode,timeAgo,} from "@dub/utils";import {@@ -47,7 +48,6 @@ import {} from "lucide-react";import Link from "next/link";import { useParams, useSearchParams } from "next/navigation";-import punycode from "punycode/";import { useEffect, useMemo, useRef, useState } from "react";import { toast } from "sonner";import useSWR, { mutate } from "swr";@@ -150,7 +150,7 @@ export default function LinkCard({// @ts-expect-errorduplicateProps: {...propsToDuplicate,- key: `${key}-copy`,+ key: `${punycode(key)}-copy`,clicks: 0,},});@@ -315,8 +315,8 @@ export default function LinkCard({><div className="max-w-[140px] -translate-x-2 cursor-not-allowed truncate text-sm font-semibold text-gray-400 line-through sm:max-w-[300px] sm:text-base md:max-w-[360px] xl:max-w-[500px]">{linkConstructor({+ domain,key,- domain: punycode.toUnicode(domain || ""),pretty: true,})}</div>@@ -329,18 +329,26 @@ export default function LinkCard({"text-gray-500": archived || expired,},)}- href={linkConstructor({ key, domain })}+ href={linkConstructor({+ domain,+ key,+ })}target="_blank"rel="noreferrer">{linkConstructor({+ domain,key,- domain: punycode.toUnicode(domain || ""),pretty: true,})}</a>)}- <CopyButton value={linkConstructor({ key, domain })} />+ <CopyButton+ value={linkConstructor({+ domain,+ key,+ })}+ />{comments && (<Tooltipcontent={diff --git a/apps/web/ui/links/link-filters.tsx b/apps/web/ui/links/link-filters.tsxindex 2918d971c6..a77482512f 100644--- a/apps/web/ui/links/link-filters.tsx+++ b/apps/web/ui/links/link-filters.tsx@@ -23,6 +23,7 @@ import {SWIPE_REVEAL_ANIMATION_SETTINGS,isDubDomain,nFormatter,+ punycode,truncate,} from "@dub/utils";import { AnimatePresence, motion } from "framer-motion";@@ -34,7 +35,6 @@ import {useRouter,useSearchParams,} from "next/navigation";-import punycode from "punycode/";import { useCallback, useEffect, useMemo, useRef, useState } from "react";import { toast } from "sonner";import { mutate } from "swr";@@ -259,7 +259,7 @@ const DomainsFilter = () => {htmlFor={domain.slug}className="flex w-full cursor-pointer items-center justify-between px-3 py-2 pl-0 text-sm font-medium text-gray-700">- <p>{truncate(punycode.toUnicode(domain.slug || ""), 24)}</p>+ <p>{truncate(punycode(domain.slug), 24)}</p><DomainPopover domain={domain} count={domain.count} /></label></div>diff --git a/apps/web/ui/modals/add-edit-link-modal/android-section.tsx b/apps/web/ui/modals/add-edit-link-modal/android-section.tsxindex 37c2e7ab34..0050b093e5 100644--- a/apps/web/ui/modals/add-edit-link-modal/android-section.tsx+++ b/apps/web/ui/modals/add-edit-link-modal/android-section.tsx@@ -1,14 +1,8 @@-import useWorkspace from "@/lib/swr/use-workspace";import { LinkProps } from "@/lib/types";-import {- InfoTooltip,- SimpleTooltipContent,- Switch,- TooltipContent,- useRouterStuff,-} from "@dub/ui";+import { BadgeTooltip, SimpleTooltipContent, Switch } from "@dub/ui";import { FADE_IN_ANIMATION_SETTINGS } from "@dub/utils";import { motion } from "framer-motion";+import { Crown } from "lucide-react";import { Dispatch, SetStateAction, useEffect, useState } from "react";export default function AndroidSection({@@ -20,8 +14,6 @@ export default function AndroidSection({data: LinkProps;setData: Dispatch<SetStateAction<LinkProps>>;}) {- const { plan } = useWorkspace();- const { queryParams } = useRouterStuff();const { android } = data;const [enabled, setEnabled] = useState(!!android);useEffect(() => {@@ -44,7 +36,7 @@ export default function AndroidSection({<h2 className="text-sm font-medium text-gray-900">Android Targeting</h2>- <InfoTooltip+ <BadgeTooltipcontent={<SimpleTooltipContenttitle="Redirect your Android users to a different link."@@ -52,35 +44,14 @@ export default function AndroidSection({href="https://dub.co/help/article/device-targeting"/>}- />+ >+ <div className="flex items-center space-x-1">+ <Crown size={12} />+ <p>PRO</p>+ </div>+ </BadgeTooltip></div>- <Switch- fn={() => setEnabled(!enabled)}- checked={enabled}- // Android targeting is only available on Dub's Pro plan- {...((!plan || plan === "free") && !enabled- ? {- disabledTooltip: (- <TooltipContent- title={`Android targeting is only available on ${process.env.NEXT_PUBLIC_APP_NAME}'s Pro plan. Upgrade to Pro to use this feature.`}- cta="Upgrade to Pro"- {...(plan === "free"- ? {- onClick: () =>- queryParams({- set: {- upgrade: "pro",- },- }),- }- : {- href: "https://dub.co/pricing",- })}- />- ),- }- : {})}- />+ <Switch fn={() => setEnabled(!enabled)} checked={enabled} /></div>{enabled && (<motion.div@@ -90,7 +61,6 @@ export default function AndroidSection({<inputname="android-url"id="android-url"- type="url"placeholder="https://play.google.com/store/apps/details?id=com.disney.disneyplus"value={android || ""}onChange={(e) => {diff --git a/apps/web/ui/modals/add-edit-link-modal/cloaking-section.tsx b/apps/web/ui/modals/add-edit-link-modal/cloaking-section.tsxindex fa0cf6618b..b0fb46a6dc 100644--- a/apps/web/ui/modals/add-edit-link-modal/cloaking-section.tsx+++ b/apps/web/ui/modals/add-edit-link-modal/cloaking-section.tsx@@ -1,16 +1,18 @@-import useWorkspace from "@/lib/swr/use-workspace";import { LinkProps } from "@/lib/types";import { AlertCircleFill, CheckCircleFill } from "@/ui/shared/icons";import {- InfoTooltip,+ BadgeTooltip,LoadingSpinner,SimpleTooltipContent,Switch,- TooltipContent,- useRouterStuff,} from "@dub/ui";-import { FADE_IN_ANIMATION_SETTINGS, fetcher } from "@dub/utils";+import {+ FADE_IN_ANIMATION_SETTINGS,+ fetcher,+ getUrlFromString,+} from "@dub/utils";import { motion } from "framer-motion";+import { Crown } from "lucide-react";import { Dispatch, SetStateAction, useEffect, useState } from "react";import useSWR from "swr";@@ -21,9 +23,6 @@ export default function CloakingSection({data: LinkProps;setData: Dispatch<SetStateAction<LinkProps>>;}) {- const { plan } = useWorkspace();- const { queryParams } = useRouterStuff();-const { rewrite } = data;const [enabled, setEnabled] = useState(rewrite);useEffect(() => {@@ -44,7 +43,7 @@ export default function CloakingSection({<div className="flex items-center justify-between"><div className="flex items-center justify-between space-x-2"><h2 className="text-sm font-medium text-gray-900">Link Cloaking</h2>- <InfoTooltip+ <BadgeTooltipcontent={<SimpleTooltipContenttitle="Mask your destination URL so your users only see the short link in the browser address bar."@@ -52,44 +51,29 @@ export default function CloakingSection({href="https://dub.co/help/article/link-cloaking"/>}- />+ >+ <div className="flex items-center space-x-1">+ <Crown size={12} />+ <p>PRO</p>+ </div>+ </BadgeTooltip></div>- <Switch- fn={() => setEnabled(!enabled)}- checked={enabled}- // link cloaking is only available on Dub's Pro plan- {...((!plan || plan === "free") && !enabled- ? {- disabledTooltip: (- <TooltipContent- title={`Link cloaking is only available on ${process.env.NEXT_PUBLIC_APP_NAME}'s Pro plan. Upgrade to Pro to use this feature.`}- cta="Upgrade to Pro"- {...(plan === "free"- ? {- onClick: () =>- queryParams({- set: {- upgrade: "pro",- },- }),- }- : {- href: "https://dub.co/pricing",- })}- />- ),- }- : {})}- />+ <Switch fn={() => setEnabled(!enabled)} checked={enabled} /></div>{enabled && (<motion.div className="mt-3 grid gap-2" {...FADE_IN_ANIMATION_SETTINGS}><div className="relative mt-1 flex aspect-[1200/630] w-full cursor-pointer items-center justify-center overflow-hidden rounded-md border border-gray-300 bg-white shadow-sm transition-all hover:bg-gray-50">- <iframe src={data.url} className="absolute z-10 h-full w-full" />+ <iframe+ src={getUrlFromString(data.url)}+ className="absolute z-10 h-full w-full"+ /><LoadingSpinner /></div>- <IframeIndicator url={data.url} domain={data.domain} />+ <IframeIndicator+ url={getUrlFromString(data.url)}+ domain={data.domain}+ /></motion.div>)}</div>diff --git a/apps/web/ui/modals/add-edit-link-modal/expiration-section.tsx b/apps/web/ui/modals/add-edit-link-modal/expiration-section.tsxindex a8e50e11d2..e436da6505 100644--- a/apps/web/ui/modals/add-edit-link-modal/expiration-section.tsx+++ b/apps/web/ui/modals/add-edit-link-modal/expiration-section.tsx@@ -1,13 +1,11 @@-import useWorkspace from "@/lib/swr/use-workspace";import { LinkProps } from "@/lib/types";import {+ BadgeTooltip,ExpandingArrow,InfoTooltip,SimpleTooltipContent,Switch,- useRouterStuff,} from "@dub/ui";-import { TooltipContent } from "@dub/ui/src/tooltip";import {FADE_IN_ANIMATION_SETTINGS,formatDateTime,@@ -15,6 +13,7 @@ import {parseDateTime,} from "@dub/utils";import { motion } from "framer-motion";+import { Crown } from "lucide-react";import { Dispatch, SetStateAction, useEffect, useRef, useState } from "react";export default function ExpirationSection({@@ -26,8 +25,6 @@ export default function ExpirationSection({data: LinkProps;setData: Dispatch<SetStateAction<LinkProps>>;}) {- const { plan } = useWorkspace();- const { queryParams } = useRouterStuff();const inputRef = useRef<HTMLInputElement>(null);const { expiresAt, expiredUrl } = data;@@ -51,7 +48,7 @@ export default function ExpirationSection({<div className="flex items-center justify-between"><div className="flex items-center justify-between space-x-2"><h2 className="text-sm font-medium text-gray-900">Link Expiration</h2>- <InfoTooltip+ <BadgeTooltipcontent={<SimpleTooltipContenttitle="Set an expiration date for your links – after which it won't be accessible."@@ -59,35 +56,14 @@ export default function ExpirationSection({href="https://dub.co/help/article/link-expiration"/>}- />+ >+ <div className="flex items-center space-x-1">+ <Crown size={12} />+ <p>PRO</p>+ </div>+ </BadgeTooltip></div>- <Switch- fn={() => setEnabled(!enabled)}- checked={enabled}- // expiration date is only available on Dub's Pro plan- {...((!plan || plan === "free") && !enabled- ? {- disabledTooltip: (- <TooltipContent- title={`Expiration date is only available on ${process.env.NEXT_PUBLIC_APP_NAME}'s Pro plan. Upgrade to Pro to use this feature.`}- cta="Upgrade to Pro"- {...(plan === "free"- ? {- onClick: () =>- queryParams({- set: {- upgrade: "pro",- },- }),- }- : {- href: "https://dub.co/pricing",- })}- />- ),- }- : {})}- />+ <Switch fn={() => setEnabled(!enabled)} checked={enabled} /></div>{enabled && (<motion.div className="mt-3" {...FADE_IN_ANIMATION_SETTINGS}>diff --git a/apps/web/ui/modals/add-edit-link-modal/geo-section.tsx b/apps/web/ui/modals/add-edit-link-modal/geo-section.tsxindex 581cba13bf..d06db088ad 100644--- a/apps/web/ui/modals/add-edit-link-modal/geo-section.tsx+++ b/apps/web/ui/modals/add-edit-link-modal/geo-section.tsx@@ -1,15 +1,8 @@-import useWorkspace from "@/lib/swr/use-workspace";import { LinkProps } from "@/lib/types";-import {- InfoTooltip,- SimpleTooltipContent,- Switch,- TooltipContent,- useRouterStuff,-} from "@dub/ui";+import { BadgeTooltip, SimpleTooltipContent, Switch } from "@dub/ui";import { COUNTRIES, FADE_IN_ANIMATION_SETTINGS } from "@dub/utils";import { motion } from "framer-motion";-import { Trash } from "lucide-react";+import { Crown, Trash } from "lucide-react";import { Dispatch, SetStateAction, useEffect, useState } from "react";export default function GeoSection({@@ -21,8 +14,6 @@ export default function GeoSection({data: LinkProps;setData: Dispatch<SetStateAction<LinkProps>>;}) {- const { plan } = useWorkspace();- const { queryParams } = useRouterStuff();const { geo } = data;const [enabled, setEnabled] = useState(!!geo);@@ -53,7 +44,7 @@ export default function GeoSection({<div className="flex items-center justify-between"><div className="flex items-center justify-between space-x-2"><h2 className="text-sm font-medium text-gray-900">Geo Targeting</h2>- <InfoTooltip+ <BadgeTooltipcontent={<SimpleTooltipContenttitle="Redirect your users to different links based on their location."@@ -61,35 +52,14 @@ export default function GeoSection({href="https://dub.co/help/article/geo-targeting"/>}- />+ >+ <div className="flex items-center space-x-1">+ <Crown size={12} />+ <p>PRO</p>+ </div>+ </BadgeTooltip></div>- <Switch- fn={() => setEnabled(!enabled)}- checked={enabled}- // geo targeting is only available on Dub's Pro plan- {...((!plan || plan === "free") && !enabled- ? {- disabledTooltip: (- <TooltipContent- title={`Geo targeting is only available on ${process.env.NEXT_PUBLIC_APP_NAME}'s Pro plan. Upgrade to Pro to use this feature.`}- cta="Upgrade to Pro"- {...(plan === "free"- ? {- onClick: () =>- queryParams({- set: {- upgrade: "pro",- },- }),- }- : {- href: "https://dub.co/pricing",- })}- />- ),- }- : {})}- />+ <Switch fn={() => setEnabled(!enabled)} checked={enabled} /></div>{enabled && (<motion.div className="mt-3 grid gap-2" {...FADE_IN_ANIMATION_SETTINGS}>@@ -164,7 +134,6 @@ const GeoSelector = ({))}</select><input- type="url"name="geo-url"requiredautoComplete="off"diff --git a/apps/web/ui/modals/add-edit-link-modal/index.tsx b/apps/web/ui/modals/add-edit-link-modal/index.tsxindex 9c6413b06e..90edef3859 100644--- a/apps/web/ui/modals/add-edit-link-modal/index.tsx+++ b/apps/web/ui/modals/add-edit-link-modal/index.tsx@@ -25,13 +25,14 @@ import {linkConstructor,truncate,} from "@dub/utils";+import { useCompletion } from "ai/react";import {useParams,usePathname,useRouter,useSearchParams,} from "next/navigation";-import punycode from "punycode/";+import punycode from "punycode";import {Dispatch,SetStateAction,@@ -55,9 +56,8 @@ import OGSection from "./og-section";import PasswordSection from "./password-section";import Preview from "./preview";import TagsSection from "./tags-section";-import UTMSection from "./utm-section";-import { useCompletion } from "ai/react";import { ButtonWithTooltip } from "./tooltip-button";+import UTMSection from "./utm-section";function AddEditLinkModal({showAddEditLinkModal,diff --git a/apps/web/ui/modals/add-edit-link-modal/ios-section.tsx b/apps/web/ui/modals/add-edit-link-modal/ios-section.tsxindex 76805405ad..db00336c8a 100644--- a/apps/web/ui/modals/add-edit-link-modal/ios-section.tsx+++ b/apps/web/ui/modals/add-edit-link-modal/ios-section.tsx@@ -1,14 +1,8 @@-import useWorkspace from "@/lib/swr/use-workspace";import { LinkProps } from "@/lib/types";-import {- InfoTooltip,- SimpleTooltipContent,- Switch,- TooltipContent,- useRouterStuff,-} from "@dub/ui";+import { BadgeTooltip, SimpleTooltipContent, Switch } from "@dub/ui";import { FADE_IN_ANIMATION_SETTINGS } from "@dub/utils";import { motion } from "framer-motion";+import { Crown } from "lucide-react";import { Dispatch, SetStateAction, useEffect, useState } from "react";export default function IOSSection({@@ -20,8 +14,6 @@ export default function IOSSection({data: LinkProps;setData: Dispatch<SetStateAction<LinkProps>>;}) {- const { plan } = useWorkspace();- const { queryParams } = useRouterStuff();const { ios } = data;const [enabled, setEnabled] = useState(!!ios);useEffect(() => {@@ -42,7 +34,7 @@ export default function IOSSection({<div className="flex items-center justify-between"><div className="flex items-center justify-between space-x-2"><h2 className="text-sm font-medium text-gray-900">iOS Targeting</h2>- <InfoTooltip+ <BadgeTooltipcontent={<SimpleTooltipContenttitle="Redirect your iOS users to a different link."@@ -50,35 +42,14 @@ export default function IOSSection({href="https://dub.co/help/article/device-targeting"/>}- />+ >+ <div className="flex items-center space-x-1">+ <Crown size={12} />+ <p>PRO</p>+ </div>+ </BadgeTooltip></div>- <Switch- fn={() => setEnabled(!enabled)}- checked={enabled}- // iOS targeting is only available on Dub's Pro plan- {...((!plan || plan === "free") && !enabled- ? {- disabledTooltip: (- <TooltipContent- title={`iOS targeting is only available on ${process.env.NEXT_PUBLIC_APP_NAME}'s Pro plan. Upgrade to Pro to use this feature.`}- cta="Upgrade to Pro"- {...(plan === "free"- ? {- onClick: () =>- queryParams({- set: {- upgrade: "pro",- },- }),- }- : {- href: "https://dub.co/pricing",- })}- />- ),- }- : {})}- />+ <Switch fn={() => setEnabled(!enabled)} checked={enabled} /></div>{enabled && (<motion.div@@ -88,7 +59,6 @@ export default function IOSSection({<inputname="ios-url"id="ios-url"- type="url"placeholder="https://apps.apple.com/app/1611158928"value={ios || ""}onChange={(e) => {diff --git a/apps/web/ui/modals/add-edit-link-modal/og-section.tsx b/apps/web/ui/modals/add-edit-link-modal/og-section.tsxindex 4d26645161..3064179cf9 100644--- a/apps/web/ui/modals/add-edit-link-modal/og-section.tsx+++ b/apps/web/ui/modals/add-edit-link-modal/og-section.tsx@@ -3,7 +3,7 @@ import useWorkspace from "@/lib/swr/use-workspace";import { LinkProps } from "@/lib/types";import { UploadCloud } from "@/ui/shared/icons";import {- InfoTooltip,+ BadgeTooltip,LoadingCircle,LoadingSpinner,Magic,@@ -13,14 +13,14 @@ import {Unsplash,} from "@dub/ui";import { FADE_IN_ANIMATION_SETTINGS } from "@dub/utils";+import { useCompletion } from "ai/react";import { motion } from "framer-motion";-import { Link2 } from "lucide-react";+import { Crown, Link2 } from "lucide-react";import { Dispatch, SetStateAction, useEffect, useState } from "react";import TextareaAutosize from "react-textarea-autosize";-import UnsplashSearch from "./unsplash-search";-import { useCompletion } from "ai/react";import { toast } from "sonner";import { ButtonWithTooltip } from "./tooltip-button";+import UnsplashSearch from "./unsplash-search";export default function OGSection({props,@@ -142,7 +142,7 @@ export default function OGSection({<h2 className="text-sm font-medium text-gray-900">Custom Social Media Cards</h2>- <InfoTooltip+ <BadgeTooltipcontent={<SimpleTooltipContenttitle="Customize how your links look when shared on social media."@@ -150,7 +150,12 @@ export default function OGSection({href="https://dub.co/help/article/custom-social-media-cards"/>}- />+ >+ <div className="flex items-center space-x-1">+ <Crown size={12} />+ <p>PRO</p>+ </div>+ </BadgeTooltip></div><Switchfn={() => setData((prev) => ({ ...prev, proxy: !proxy }))}diff --git a/apps/web/ui/modals/add-edit-link-modal/password-section.tsx b/apps/web/ui/modals/add-edit-link-modal/password-section.tsxindex 330bef36ec..d07c65baad 100644--- a/apps/web/ui/modals/add-edit-link-modal/password-section.tsx+++ b/apps/web/ui/modals/add-edit-link-modal/password-section.tsx@@ -1,15 +1,9 @@-import useWorkspace from "@/lib/swr/use-workspace";import { LinkProps } from "@/lib/types";import { Eye, EyeOff } from "@/ui/shared/icons";-import {- InfoTooltip,- SimpleTooltipContent,- Switch,- useRouterStuff,-} from "@dub/ui";-import { TooltipContent } from "@dub/ui/src/tooltip";+import { BadgeTooltip, SimpleTooltipContent, Switch } from "@dub/ui";import { FADE_IN_ANIMATION_SETTINGS } from "@dub/utils";import { motion } from "framer-motion";+import { Crown } from "lucide-react";import { Dispatch, SetStateAction, useEffect, useState } from "react";export default function PasswordSection({@@ -21,9 +15,6 @@ export default function PasswordSection({data: LinkProps;setData: Dispatch<SetStateAction<LinkProps>>;}) {- const { plan } = useWorkspace();- const { queryParams } = useRouterStuff();-const { password } = data;const [enabled, setEnabled] = useState(!!password);useEffect(() => {@@ -48,7 +39,7 @@ export default function PasswordSection({<h2 className="text-sm font-medium text-gray-900">Password Protection</h2>- <InfoTooltip+ <BadgeTooltipcontent={<SimpleTooltipContenttitle="Restrict access to your short links by encrypting it with a password."@@ -56,35 +47,14 @@ export default function PasswordSection({href="https://dub.co/help/article/password-protected-links"/>}- />+ >+ <div className="flex items-center space-x-1">+ <Crown size={12} />+ <p>PRO</p>+ </div>+ </BadgeTooltip></div>- <Switch- fn={() => setEnabled(!enabled)}- checked={enabled}- // password protection is only available on Dub's Pro plan- {...((!plan || plan === "free") && !enabled- ? {- disabledTooltip: (- <TooltipContent- title={`Password protection is only available on ${process.env.NEXT_PUBLIC_APP_NAME}'s Pro plan. Upgrade to Pro to use this feature.`}- cta="Upgrade to Pro"- {...(plan === "free"- ? {- onClick: () =>- queryParams({- set: {- upgrade: "pro",- },- }),- }- : {- href: "https://dub.co/pricing",- })}- />- ),- }- : {})}- />+ <Switch fn={() => setEnabled(!enabled)} checked={enabled} /></div>{enabled && (<motion.divdiff --git a/apps/web/ui/modals/link-qr-modal.tsx b/apps/web/ui/modals/link-qr-modal.tsxindex f1c1d74494..7b8c3cc606 100644--- a/apps/web/ui/modals/link-qr-modal.tsx+++ b/apps/web/ui/modals/link-qr-modal.tsx@@ -80,6 +80,9 @@ export function QRCodePicker({value: linkConstructor({key: props.key,domain: props.domain,+ searchParams: {+ qr: "1",+ },}),bgColor: "#ffffff",fgColor,@@ -190,6 +193,9 @@ export function QRCodePicker({`https://api.dub.co/qr?url=${linkConstructor({key: props.key,domain: props.domain,+ searchParams: {+ qr: "1",+ },})}`,);toast.success("Copied QR code URL to clipboard!");diff --git a/apps/web/ui/workspaces/workspace-card.tsx b/apps/web/ui/workspaces/workspace-card.tsxindex 77ffc88456..4b54b7d22f 100644--- a/apps/web/ui/workspaces/workspace-card.tsx+++ b/apps/web/ui/workspaces/workspace-card.tsx@@ -11,7 +11,13 @@ import {NumberTooltip,Tooltip,} from "@dub/ui";-import { DICEBEAR_AVATAR_URL, cn, fetcher, nFormatter } from "@dub/utils";+import {+ DICEBEAR_AVATAR_URL,+ cn,+ fetcher,+ nFormatter,+ punycode,+} from "@dub/utils";import {BarChart2,ExternalLink,@@ -20,7 +26,6 @@ import {MinusCircle,} from "lucide-react";import Link from "next/link";-import punycode from "punycode/";import useSWR from "swr";import useSWRImmutable from "swr/immutable";import PlanBadge from "./plan-badge";@@ -222,7 +227,7 @@ const DomainsTooltip = ({<XCircleFill className="h-5 w-5 text-gray-300" />)}<p className="text-sm font-semibold text-gray-500">- {punycode.toUnicode(slug)}+ {punycode(slug)}</p></div><ExternalLink className="h-4 w-4 text-gray-500 md:invisible md:group-hover:visible" />diff --git a/packages/ui/package.json b/packages/ui/package.jsonindex 3685090e6a..e7e823b4bf 100644--- a/packages/ui/package.json+++ b/packages/ui/package.json@@ -26,7 +26,7 @@"@types/js-cookie": "^3.0.6","@types/react": "^18.2.47","autoprefixer": "^10.4.16",- "next": "14.2.0-canary.47",+ "next": "14.2.0-canary.67","postcss": "^8.4.31","react": "^18.2.0","tailwindcss": "^3.3.3",@@ -50,7 +50,7 @@"framer-motion": "^10.16.16","js-cookie": "^3.0.5","linkify-react": "^4.1.3",- "lucide-react": "^0.284.0",+ "lucide-react": "^0.367.0","sonner": "^1.4.41","swr": "^2.1.5","use-debounce": "^8.0.4",diff --git a/packages/ui/src/icons/linkedin.tsx b/packages/ui/src/icons/linkedin.tsxindex 874b6cda2c..c68f80d239 100644--- a/packages/ui/src/icons/linkedin.tsx+++ b/packages/ui/src/icons/linkedin.tsx@@ -1,3 +1,5 @@+import { cn } from "@dub/utils";+export default function LinkedIn({ className }: { className?: string }) {return (<svg@@ -5,7 +7,7 @@ export default function LinkedIn({ className }: { className?: string }) {width="24"height="24"viewBox="0 0 24 24"- className={className}+ className={cn("text-[#0077b5]", className)}><pathfill="currentColor"diff --git a/packages/ui/src/icons/twitter.tsx b/packages/ui/src/icons/twitter.tsxindex 70c17acffe..65567ac0b7 100644--- a/packages/ui/src/icons/twitter.tsx+++ b/packages/ui/src/icons/twitter.tsx@@ -1,3 +1,5 @@+import { cn } from "@dub/utils";+export default function Twitter({ className }: { className?: string }) {return (<svg@@ -6,7 +8,7 @@ export default function Twitter({ className }: { className?: string }) {viewBox="0 0 300 300"version="1.1"xmlns="http://www.w3.org/2000/svg"- className={className}+ className={cn("p-px", className)}><pathstroke="currentColor"diff --git a/packages/ui/src/tooltip.tsx b/packages/ui/src/tooltip.tsxindex efe30c6cb6..4e2fe4ebd9 100644--- a/packages/ui/src/tooltip.tsx+++ b/packages/ui/src/tooltip.tsx@@ -180,13 +180,9 @@ export function NumberTooltip({);}-export function BadgeTooltip({- children,- content,- side = "bottom",-}: TooltipProps) {+export function BadgeTooltip({ children, content, ...props }: TooltipProps) {return (- <Tooltip content={content} side={side}>+ <Tooltip content={content} {...props}><div className="flex cursor-pointer items-center"><Badgevariant="gray"diff --git a/packages/utils/package.json b/packages/utils/package.jsonindex 552741a6ab..46b5f55ce6 100644--- a/packages/utils/package.json+++ b/packages/utils/package.json@@ -1,7 +1,7 @@{"name": "@dub/utils","description": "Utility functions and constants for Dub.co",- "version": "0.0.47",+ "version": "0.0.48","sideEffects": false,"main": "./dist/index.mjs","module": "./dist/index.mjs",@@ -22,8 +22,9 @@"devDependencies": {"@types/ms": "^0.7.31","@types/node": "18.11.9",+ "@types/punycode": "^2.1.4","@types/react": "^18.2.5",- "next": "14.2.0-canary.47",+ "next": "14.2.0-canary.67","react": "^18.2.0","tsconfig": "workspace:*","tsup": "^6.1.3",@@ -35,6 +36,7 @@"clsx": "^2.1.0","ms": "^2.1.3","nanoid": "^5.0.1",+ "punycode": "^2.3.0","tailwind-merge": "^2.2.1"},"author": "Steven Tey <[email protected]>",diff --git a/packages/utils/src/functions/datetime.ts b/packages/utils/src/functions/datetime.tsindex 53316bd682..68fe48003a 100644--- a/packages/utils/src/functions/datetime.ts+++ b/packages/utils/src/functions/datetime.ts@@ -17,6 +17,7 @@ export const parseDateTime = (str: Date | string) => {};export const formatDate = (datetime: Date | string) => {+ if (datetime.toString() === "Invalid Date") return "";return new Date(datetime).toLocaleDateString("en-US", {day: "numeric",month: "long",@@ -26,6 +27,7 @@ export const formatDate = (datetime: Date | string) => {};export const formatDateTime = (datetime: Date | string) => {+ if (datetime.toString() === "Invalid Date") return "";return new Date(datetime).toLocaleTimeString("en-US", {month: "short",day: "numeric",diff --git a/packages/utils/src/functions/domains.ts b/packages/utils/src/functions/domains.tsindex bc1e1784e8..faecc1ab4d 100644--- a/packages/utils/src/functions/domains.ts+++ b/packages/utils/src/functions/domains.ts@@ -33,7 +33,9 @@ export const validDomainRegex = new RegExp(/^([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,);-export const validKeyRegex = new RegExp(/^[0-9A-Za-z\u0080-\uFFFF\/\-]*$/u);+export const validKeyRegex = new RegExp(+ /^[0-9A-Za-z\u0080-\uFFFF\/\-\p{Emoji}]*$/u,+);export const validSlugRegex = new RegExp(/^[a-zA-Z0-9\-]+$/);diff --git a/packages/utils/src/functions/index.ts b/packages/utils/src/functions/index.tsindex 7b59effd08..87c6ee521e 100644--- a/packages/utils/src/functions/index.ts+++ b/packages/utils/src/functions/index.ts@@ -13,6 +13,7 @@ export * from "./link-constructor";export * from "./log";export * from "./nanoid";export * from "./nformatter";+export * from "./punycode";export * from "./time-ago";export * from "./trim";export * from "./truncate";diff --git a/packages/utils/src/functions/link-constructor.ts b/packages/utils/src/functions/link-constructor.tsindex 2668e8d128..5c950dfac8 100644--- a/packages/utils/src/functions/link-constructor.ts+++ b/packages/utils/src/functions/link-constructor.ts@@ -1,20 +1,29 @@+import { punycode } from ".";+export function linkConstructor({- domain = "dub.sh",+ domain,key,- localhost,pretty,- noDomain,+ searchParams,}: {domain?: string;key?: string;- localhost?: boolean;pretty?: boolean;- noDomain?: boolean;+ searchParams?: Record<string, string>;}) {- const link = `${- localhost ? "http://home.localhost:8888" : `https://${domain}`- }${key && key !== "_root" ? `/${key}` : ""}`;+ if (!domain) {+ return "";+ }++ let url = `https://${punycode(domain)}${key && key !== "_root" ? `/${punycode(key)}` : ""}`;++ if (searchParams) {+ const search = new URLSearchParams();+ for (const [key, value] of Object.entries(searchParams)) {+ search.set(key, value);+ }+ url += `?${search.toString()}`;+ }- if (noDomain) return `/${key}`;- return pretty ? link.replace(/^https?:\/\//, "") : link;+ return pretty ? url.replace(/^https?:\/\//, "") : url;}diff --git a/packages/utils/src/functions/punycode.ts b/packages/utils/src/functions/punycode.tsnew file mode 100644index 0000000000..f78f05604a--- /dev/null+++ b/packages/utils/src/functions/punycode.ts@@ -0,0 +1,15 @@+import punycodeHelper from "punycode/";++export function punycode(str?: string | null) {+ if (typeof str !== "string") return "";+ try {+ return punycodeHelper.toUnicode(str);+ } catch (e) {+ return str;+ }+}++export function punyEncode(str?: string | null) {+ if (typeof str !== "string") return "";+ return punycodeHelper.toASCII(str);+}diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 800bdf71d8..b3f0cb7a8b 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -179,17 +179,17 @@ importers:specifier: ^3.10.1version: 3.10.1lucide-react:- specifier: ^0.299.0- version: 0.299.0([email protected])+ specifier: ^0.367.0+ version: 0.367.0([email protected])nanoid:specifier: ^5.0.1version: 5.0.1next:- specifier: 14.2.0-canary.47- version: 14.2.0-canary.47(@babel/[email protected])(@opentelemetry/[email protected])([email protected])([email protected])+ specifier: 14.2.0-canary.67+ version: 14.2.0-canary.67(@babel/[email protected])(@opentelemetry/[email protected])([email protected])([email protected])next-auth:specifier: ^4.24.4node-html-parser:specifier: ^6.1.4version: 6.1.4@@ -211,9 +211,6 @@ importers:prisma:specifier: ^5.9.1version: 5.10.2- punycode:- specifier: ^2.3.0- version: 2.3.0react:specifier: ^18.2.0version: 18.2.0@@ -432,8 +429,8 @@ importers:specifier: ^4.1.3version: 4.1.3([email protected])([email protected])lucide-react:- specifier: ^0.284.0- version: 0.284.0([email protected])+ specifier: ^0.367.0+ version: 0.367.0([email protected])sonner:specifier: ^1.4.41version: 1.4.41([email protected])([email protected])@@ -463,8 +460,8 @@ importers:specifier: ^10.4.16version: 10.4.16([email protected])next:- specifier: 14.2.0-canary.47- version: 14.2.0-canary.47(@babel/[email protected])(@opentelemetry/[email protected])([email protected])([email protected])+ specifier: 14.2.0-canary.67+ version: 14.2.0-canary.67(@babel/[email protected])(@opentelemetry/[email protected])([email protected])([email protected])postcss:specifier: ^8.4.31version: 8.4.31@@ -501,6 +498,9 @@ importers:nanoid:specifier: ^5.0.1version: 5.0.1+ punycode:+ specifier: ^2.3.0+ version: 2.3.0tailwind-merge:specifier: ^2.2.1version: 2.2.1@@ -511,12 +511,15 @@ importers:'@types/node':specifier: 18.11.9version: 18.11.9+ '@types/punycode':+ specifier: ^2.1.4+ version: 2.1.4'@types/react':specifier: ^18.2.5version: 18.2.14next:- specifier: 14.2.0-canary.47- version: 14.2.0-canary.47(@babel/[email protected])(@opentelemetry/[email protected])([email protected])([email protected])+ specifier: 14.2.0-canary.67+ version: 14.2.0-canary.67(@babel/[email protected])(@opentelemetry/[email protected])([email protected])([email protected])react:specifier: ^18.2.0version: 18.2.0@@ -3480,7 +3483,7 @@ packages:next-auth: ^4dependencies:'@prisma/client': 5.10.2([email protected])dev: false/@next/[email protected]:@@ -3491,8 +3494,8 @@ packages:resolution: {integrity: sha512-dvNzrArTfe3VY1VIscpb3E2e7SZ1qwFe82WGzpOVbxilT3JcsnVGYF/uq8Jj1qKWPI5C/aePNXwA97JRNAXpRQ==}dev: false- /@next/[email protected]:- resolution: {integrity: sha512-AURjF/V33qm2JSik8jS6wz4R0kl4uhi1m8k1z4x8wxYi0KbO5YgFvqWRFr7hKy1wr9pJW39kwFgci2XftxDFww==}+ /@next/[email protected]:+ resolution: {integrity: sha512-FxcPBKXwMuoW1zzG17xAcF7449Nmxc+btAkoNPW9qNuQuWCeG2+cBxl+QZ25KUdW7BS42WrrctmNKlez9NZSLA==}/@next/[email protected]:resolution: {integrity: sha512-F3/6Z8LH/pGlPzR1AcjPFxx35mPqjE5xZcf+IL+KgbW9tMkp7CYi1y7qKrEWU7W4AumxX/8OINnDQWLiwLasLQ==}@@ -3530,8 +3533,8 @@ packages:dev: falseoptional: true- /@next/[email protected]:- resolution: {integrity: sha512-9nemlI7DMtq1OB3r4pxuVz1nU8rMEk/e7QBO1Hc+Ss+Z98HhvlqzFIShmS6LwQKa0q6KEKOdufFwtU9WG5FXTw==}+ /@next/[email protected]:+ resolution: {integrity: sha512-As/z6gEYyypV/NgZtqZ3SiR2SDfv0FApJM5oPZxaiKZc2HUdLBeKtfYBEW2Py/L92w6Wn6JX0eMt4CGx1EOiFw==}engines: {node: '>= 10'}cpu: [arm64]os: [darwin]@@ -3556,8 +3559,8 @@ packages:dev: falseoptional: true- /@next/[email protected]:- resolution: {integrity: sha512-eq3ZnKg/h9Nmy7ocTOp+3v8F9id2Ar10TCBMz/JZmreeKNpNfUznIMsdNVMgqXbXoFCpLDbIMLf4qmVF3+OlQg==}+ /@next/[email protected]:+ resolution: {integrity: sha512-r4Dn84ftDuYY3mFMgK/pi5py/QmsGEWjPDmGIritWgXuKIOKWAefUqH1Hw+iAHhUiqNRx97/0Fc3aRuTVcRr8w==}engines: {node: '>= 10'}cpu: [x64]os: [darwin]@@ -3600,8 +3603,8 @@ packages:dev: falseoptional: true- /@next/[email protected]:- resolution: {integrity: sha512-CopkMncPw34uIh11KK9XtKjSjCS/R40TDRjXI+nq33y0WPfamQMKY5HgjL27qi6Yt5XbJwZhBVZx13vSC5u1Aw==}+ /@next/[email protected]:+ resolution: {integrity: sha512-TIpXkP0EDsYhC2Yt2biDr/O/lyB7MEdT0Q1lAfKdW9iKhHcPGPd7BEFDspDNllHHuv5HtIblNGdRkE1h/BILOA==}engines: {node: '>= 10'}cpu: [arm64]os: [linux]@@ -3626,8 +3629,8 @@ packages:dev: falseoptional: true- /@next/[email protected]:- resolution: {integrity: sha512-T0Z8ECr3QerlsDAYjreyg3A6gof12dCC7sdCeTBMhLZw4JjhITfg1jrUUVWFJrASBQaYwEip001jJpyIt7NPmg==}+ /@next/[email protected]:+ resolution: {integrity: sha512-X4oFUgSPR0AfUMWDFsRo6bQZAHrQGrGcGxsV6x7tw+ySUc0mN+s1dSGJj+Wdk8a9l8a/gl5dgk91yVnIB/GKUQ==}engines: {node: '>= 10'}cpu: [arm64]os: [linux]@@ -3652,8 +3655,8 @@ packages:dev: falseoptional: true- /@next/[email protected]:- resolution: {integrity: sha512-IqaXu8km8fH3/tzluq5Arc6Yt2GaZuFF/P+uCY82MunLN+TN5FGdLpRRUbCnzlGuxTomhY4z9mRNL+3xSJP/Jg==}+ /@next/[email protected]:+ resolution: {integrity: sha512-mGttUCKgz8j+5f5mYoWrY3GKstmHHEKSAOTSasgMXy2ULhtq5rkeW7HSIWDeOZG40NsiUErSkTxzeJC2ac0wuA==}engines: {node: '>= 10'}cpu: [x64]os: [linux]@@ -3678,8 +3681,8 @@ packages:dev: falseoptional: true- /@next/[email protected]:- resolution: {integrity: sha512-0UluZrjveAaTmW9sNZcbhgL8Hyi1hiQzS4njau7T480M6L+dPSWx3c4W029dSBJrBVquB5mwUzjtcIQoFZPCWw==}+ /@next/[email protected]:+ resolution: {integrity: sha512-n3VmGvqEfV/qpvL5H0nhtQgWklHqReZbMZ7Mas674lZU+11fHKwALcEO5H/5BBz1NjegHPag7pXbtGJR9FQKWw==}engines: {node: '>= 10'}cpu: [x64]os: [linux]@@ -3704,8 +3707,8 @@ packages:dev: falseoptional: true- /@next/[email protected]:- resolution: {integrity: sha512-dEHvVCNlKUOMD2w8jXMIQy+/0OQHU5EHycamS5zL9cleHX2JJEyy0V0amJYJsc+26NRRSCUDC26xjCQNL27x6g==}+ /@next/[email protected]:+ resolution: {integrity: sha512-lmgTWoZzz6Rdg+zPcezG4cSXGLiBiNQHDt3HHQHJSoQ2hnFSq0DrtZXhcKSNDyXdQDoV0xRmc86+ll2hz2lp4Q==}engines: {node: '>= 10'}cpu: [arm64]os: [win32]@@ -3730,8 +3733,8 @@ packages:dev: falseoptional: true- /@next/[email protected]:- resolution: {integrity: sha512-BJP9qLYP4n9XXOzj/mTpPRS3F4/+fduDrr5HfGp++lo898MX3wG9Mq4mrkr7WWzzlU3nuehHE9DLEwyFHtyi9w==}+ /@next/[email protected]:+ resolution: {integrity: sha512-IfH9+mhIlJdoAK9PIWhTaodhUrEQGGUm8T6up0Rx4S7v/CPqFOE8IMYP/AxwCxUPJgMPQCWvnu6rw91VjVrvNg==}engines: {node: '>= 10'}cpu: [ia32]os: [win32]@@ -3756,8 +3759,8 @@ packages:dev: falseoptional: true- /@next/[email protected]:- resolution: {integrity: sha512-Ee/xNaiP2S0y9emmumoqa9poi6e7oWxYZajJpbXcRIT8hURzRYgAN0+YaX86Y33M2XJ9UIX0KcUSXjCQ9zPQuA==}+ /@next/[email protected]:+ resolution: {integrity: sha512-xqQ7F966J1WPIV6nND87vYnUfyVIX6RgE3w1AdfpHsW+97EWrHxrBEx7nRPA1FzoiYGD0LGYJU91I3MuwCjYug==}engines: {node: '>= 10'}cpu: [x64]os: [win32]@@ -5069,7 +5072,7 @@ packages:'@types/react-dom':optional: truedependencies:- '@babel/runtime': 7.23.9+ '@babel/runtime': 7.23.2'@radix-ui/primitive': 1.0.1'@radix-ui/react-collection': 1.0.3(@types/[email protected])(@types/[email protected])([email protected])([email protected])'@radix-ui/react-compose-refs': 1.0.1(@types/[email protected])([email protected])@@ -7028,6 +7031,10 @@ packages:/@types/[email protected]:resolution: {integrity: sha512-kMpQpfZKSCBqltAJwskgePRaYRFukDkm1oItcAbC3gNELR20XIBcN9VRgg4+m8DKsTfkWeA4m4Imp4DDuWy7FQ==}+ /@types/[email protected]:+ resolution: {integrity: sha512-trzh6NzBnq8yw5e35f8xe8VTYjqM3NE7bohBtvDVf/dtUer3zYTLK1Ka3DG3p7bdtoaOHZucma6FfVKlQ134pQ==}+ dev: true+/@types/[email protected]:resolution: {integrity: sha512-V835xgdSVmyQmI1KLV2BEIUgqEuinxp9O4G6g3FqO/SqLac049E53aysv0oEFD2kHfejeKU+ZqL2bcFWj9gLAQ==}dependencies:@@ -11403,16 +11410,8 @@ packages:engines: {node: '>=16.14'}dev: false- resolution: {integrity: sha512-dVSMHYAya/TeY3+vsk+VQJEKNQN2AhIo0+Dp09B2qpzvcBuu93H98YZykFcjIAfmanFiDd8nqfXFR38L757cyQ==}- peerDependencies:- react: ^16.5.1 || ^17.0.0 || ^18.0.0- dependencies:- react: 18.2.0- dev: false-- resolution: {integrity: sha512-59MiDzDzFI/efHhb4n0vGdXelMNwou7JlAFvVS4boA1G/7aYU7garPciYo73CODzkhrhz0JOgdtSTPSe5dMrlQ==}+ resolution: {integrity: sha512-3FWiBaJiqMrx5a1sjH3CVdPqWnw/Z/PTVeeTDmOeILSs+8Ah+VhCd4FQMeHo6Z0WxHcm9piIOtilQwvceiCCKQ==}peerDependencies:react: ^16.5.1 || ^17.0.0 || ^18.0.0dependencies:@@ -12413,7 +12412,7 @@ packages:resolution: {integrity: sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==}dev: falseresolution: {integrity: sha512-5DGffi+OpkbU62vPQIJ1z+hFnmow+ec5Qrn9m6eoglIO51m0DlrmLxBduZEwKAYDEg9k2joi1yelgmq1vqK3aQ==}peerDependencies:next: ^12.2.5 || ^13 || ^14@@ -12428,7 +12427,7 @@ packages:'@panva/hkdf': 1.1.1cookie: 0.5.0jose: 4.15.4- next: 14.2.0-canary.47(@babel/[email protected])(@opentelemetry/[email protected])([email protected])([email protected])+ next: 14.2.0-canary.67(@babel/[email protected])(@opentelemetry/[email protected])([email protected])([email protected])nodemailer: 6.9.3oauth: 0.9.15openid-client: 5.6.1@@ -12523,8 +12522,8 @@ packages:- babel-plugin-macrosdev: false- /[email protected](@babel/[email protected])(@opentelemetry/[email protected])([email protected])([email protected]):- resolution: {integrity: sha512-gtOUWhd+diNCTeRQAMFVRFx2Fo6WKCfFWZ+yg/2TgUnF1dc+tMFU0OYjXM1NRs4Yc6jdyqzeanH3oYYSokwg1w==}+ /[email protected](@babel/[email protected])(@opentelemetry/[email protected])([email protected])([email protected]):+ resolution: {integrity: sha512-8P24aAwZJXt3WTvB4qT6KDcw/PFFMsTYsDG704IeprQIG4WZjJxuhs09sp3fodr0ZX3ulvaNL1yD8V/eb4Bi/w==}engines: {node: '>=18.17.0'}hasBin: truepeerDependencies:@@ -12541,7 +12540,7 @@ packages:sass:optional: truedependencies:- '@next/env': 14.2.0-canary.47+ '@next/env': 14.2.0-canary.67'@opentelemetry/api': 1.4.1'@swc/helpers': 0.5.5busboy: 1.6.0@@ -12552,15 +12551,15 @@ packages:react-dom: 18.2.0([email protected])styled-jsx: 5.1.1(@babel/[email protected])([email protected])optionalDependencies:- '@next/swc-darwin-arm64': 14.2.0-canary.47- '@next/swc-darwin-x64': 14.2.0-canary.47- '@next/swc-linux-arm64-gnu': 14.2.0-canary.47- '@next/swc-linux-arm64-musl': 14.2.0-canary.47- '@next/swc-linux-x64-gnu': 14.2.0-canary.47- '@next/swc-linux-x64-musl': 14.2.0-canary.47- '@next/swc-win32-arm64-msvc': 14.2.0-canary.47- '@next/swc-win32-ia32-msvc': 14.2.0-canary.47- '@next/swc-win32-x64-msvc': 14.2.0-canary.47+ '@next/swc-darwin-arm64': 14.2.0-canary.67+ '@next/swc-darwin-x64': 14.2.0-canary.67+ '@next/swc-linux-arm64-gnu': 14.2.0-canary.67+ '@next/swc-linux-arm64-musl': 14.2.0-canary.67+ '@next/swc-linux-x64-gnu': 14.2.0-canary.67+ '@next/swc-linux-x64-musl': 14.2.0-canary.67+ '@next/swc-win32-arm64-msvc': 14.2.0-canary.67+ '@next/swc-win32-ia32-msvc': 14.2.0-canary.67+ '@next/swc-win32-x64-msvc': 14.2.0-canary.67transitivePeerDependencies:- '@babel/core'- babel-plugin-macros