The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Migrate to next-axiom
Steven Tey5dcb2de924e0
diff --git a/apps/web/app/layout.tsx b/apps/web/app/layout.tsxindex 3e4d362623..71744da5f3 100644--- a/apps/web/app/layout.tsx+++ b/apps/web/app/layout.tsx@@ -5,6 +5,7 @@ import { TooltipProvider } from "@dub/ui/src/tooltip";import { cn, constructMetadata } from "@dub/utils";import { Analytics as VercelAnalytics } from "@vercel/analytics/react";import { SpeedInsights } from "@vercel/speed-insights/next";+import { AxiomWebVitals } from "next-axiom";import { Toaster } from "sonner";export const metadata = constructMetadata();@@ -17,6 +18,7 @@ export default function RootLayout({return (<html lang="en" className={cn(satoshi.variable, inter.variable)}><body>+ <AxiomWebVitals /><TooltipProvider><Toaster closeButton className="pointer-events-auto" />{children}diff --git a/apps/web/lib/auth/session.ts b/apps/web/lib/auth/session.tsindex f301080b02..dae9141ffd 100644--- a/apps/web/lib/auth/session.ts+++ b/apps/web/lib/auth/session.ts@@ -3,6 +3,7 @@ import { prisma } from "@/lib/prisma";import { ratelimit } from "@/lib/upstash";import { getSearchParams } from "@dub/utils";import { waitUntil } from "@vercel/functions";+import { AxiomRequest, withAxiom } from "next-axiom";import { hashToken } from "./hash-token";import { Session, getSession } from "./utils";@@ -20,100 +21,102 @@ interface WithSessionHandler {}): Promise<Response>;}-export const withSession =- (handler: WithSessionHandler) =>- async (- req: Request,- { params = {} }: { params: Record<string, string> | undefined },- ) => {- try {- let session: Session | undefined;- let headers = {};+export const withSession = (handler: WithSessionHandler) =>+ withAxiom(+ async (+ req: AxiomRequest,+ { params = {} }: { params: Record<string, string> | undefined },+ ) => {+ try {+ let session: Session | undefined;+ let headers = {};- const authorizationHeader = req.headers.get("Authorization");- if (authorizationHeader) {- if (!authorizationHeader.includes("Bearer ")) {- throw new DubApiError({- code: "bad_request",- message:- "Misconfigured authorization header. Did you forget to add 'Bearer '? Learn more: https://d.to/auth",- });- }- const apiKey = authorizationHeader.replace("Bearer ", "");+ const authorizationHeader = req.headers.get("Authorization");+ if (authorizationHeader) {+ if (!authorizationHeader.includes("Bearer ")) {+ throw new DubApiError({+ code: "bad_request",+ message:+ "Misconfigured authorization header. Did you forget to add 'Bearer '? Learn more: https://d.to/auth",+ });+ }+ const apiKey = authorizationHeader.replace("Bearer ", "");- const hashedKey = await hashToken(apiKey);+ const hashedKey = await hashToken(apiKey);- const user = await prisma.user.findFirst({- where: {- tokens: {- some: {- hashedKey,+ const user = await prisma.user.findFirst({+ where: {+ tokens: {+ some: {+ hashedKey,+ },},},- },- select: {- id: true,- name: true,- email: true,- isMachine: true,- },- });- if (!user) {- throw new DubApiError({- code: "unauthorized",- message: "Unauthorized: Invalid API key.",+ select: {+ id: true,+ name: true,+ email: true,+ isMachine: true,+ },});- }+ if (!user) {+ throw new DubApiError({+ code: "unauthorized",+ message: "Unauthorized: Invalid API key.",+ });+ }- const { success, limit, reset, remaining } = await ratelimit(- 600,- "1 m",- ).limit(apiKey);+ const { success, limit, reset, remaining } = await ratelimit(+ 600,+ "1 m",+ ).limit(apiKey);- headers = {- "Retry-After": reset.toString(),- "X-RateLimit-Limit": limit.toString(),- "X-RateLimit-Remaining": remaining.toString(),- "X-RateLimit-Reset": reset.toString(),- };+ headers = {+ "Retry-After": reset.toString(),+ "X-RateLimit-Limit": limit.toString(),+ "X-RateLimit-Remaining": remaining.toString(),+ "X-RateLimit-Reset": reset.toString(),+ };- if (!success) {- return new Response("Too many requests.", {- status: 429,- headers,- });- }- waitUntil(- prisma.token.update({- where: {- hashedKey,- },- data: {- lastUsed: new Date(),+ if (!success) {+ return new Response("Too many requests.", {+ status: 429,+ headers,+ });+ }+ waitUntil(+ prisma.token.update({+ where: {+ hashedKey,+ },+ data: {+ lastUsed: new Date(),+ },+ }),+ );+ session = {+ user: {+ id: user.id,+ name: user.name || "",+ email: user.email || "",+ isMachine: user.isMachine,},- }),- );- session = {- user: {- id: user.id,- name: user.name || "",- email: user.email || "",- isMachine: user.isMachine,- },- };- } else {- session = await getSession();- if (!session?.user.id) {- throw new DubApiError({- code: "unauthorized",- message: "Unauthorized: Login required.",- });+ };+ } else {+ session = await getSession();+ if (!session?.user.id) {+ throw new DubApiError({+ code: "unauthorized",+ message: "Unauthorized: Login required.",+ });+ }}- }- const searchParams = getSearchParams(req.url);- return await handler({ req, params, searchParams, session });- } catch (error) {- return handleAndReturnErrorResponse(error);- }- };+ const searchParams = getSearchParams(req.url);+ return await handler({ req, params, searchParams, session });+ } catch (error) {+ req.log.error(error);+ return handleAndReturnErrorResponse(error);+ }+ },+ );diff --git a/apps/web/lib/auth/workspace-edge.ts b/apps/web/lib/auth/workspace-edge.tsindex ad7822a0ac..57e579e641 100644--- a/apps/web/lib/auth/workspace-edge.ts+++ b/apps/web/lib/auth/workspace-edge.ts@@ -9,6 +9,7 @@ import { API_DOMAIN, getSearchParams } from "@dub/utils";import { waitUntil } from "@vercel/functions";import { StreamingTextResponse } from "ai";import { getToken } from "next-auth/jwt";+import { AxiomRequest, withAxiom } from "next-axiom";import { NextRequest } from "next/server";import { throwIfNoAccess } from "../api/tokens/permissions";import {@@ -68,334 +69,337 @@ export const withWorkspaceEdge = (requiredPermissions?: PermissionAction[];} = {},) => {- return async (- req: Request,- { params = {} }: { params: Record<string, string> | undefined },- ) => {- const searchParams = getSearchParams(req.url);-- let apiKey: string | undefined = undefined;- let headers = {};-- try {- const authorizationHeader = req.headers.get("Authorization");- if (authorizationHeader) {- if (!authorizationHeader.includes("Bearer ")) {+ return withAxiom(+ async (+ req: AxiomRequest,+ { params = {} }: { params: Record<string, string> | undefined },+ ) => {+ const searchParams = getSearchParams(req.url);++ let apiKey: string | undefined = undefined;+ let headers = {};++ try {+ const authorizationHeader = req.headers.get("Authorization");+ if (authorizationHeader) {+ if (!authorizationHeader.includes("Bearer ")) {+ throw new DubApiError({+ code: "bad_request",+ message:+ "Misconfigured authorization header. Did you forget to add 'Bearer '? Learn more: https://d.to/auth",+ });+ }+ apiKey = authorizationHeader.replace("Bearer ", "");+ }++ let session: Session | undefined;+ let workspaceId: string | undefined;+ let workspaceSlug: string | undefined;+ let permissions: PermissionAction[] = [];+ let token: any | null = null;+ const isRestrictedToken = apiKey?.startsWith("dub_");++ const idOrSlug =+ params?.idOrSlug ||+ searchParams.workspaceId ||+ params?.slug ||+ searchParams.projectSlug;++ // if there's no workspace ID or slug and it's not a restricted token+ // For restricted tokens, we find the workspaceId from the token+ if (!idOrSlug && !isRestrictedToken) {throw new DubApiError({- code: "bad_request",+ code: "not_found",message:- "Misconfigured authorization header. Did you forget to add 'Bearer '? Learn more: https://d.to/auth",+ "Workspace id not found. Did you forget to include a `workspaceId` query parameter? Learn more: https://d.to/id",});}- apiKey = authorizationHeader.replace("Bearer ", "");- }- let session: Session | undefined;- let workspaceId: string | undefined;- let workspaceSlug: string | undefined;- let permissions: PermissionAction[] = [];- let token: any | null = null;- const isRestrictedToken = apiKey?.startsWith("dub_");-- const idOrSlug =- params?.idOrSlug ||- searchParams.workspaceId ||- params?.slug ||- searchParams.projectSlug;-- // if there's no workspace ID or slug and it's not a restricted token- // For restricted tokens, we find the workspaceId from the token- if (!idOrSlug && !isRestrictedToken) {- throw new DubApiError({- code: "not_found",- message:- "Workspace id not found. Did you forget to include a `workspaceId` query parameter? Learn more: https://d.to/id",- });- }+ if (idOrSlug) {+ if (idOrSlug.startsWith("ws_")) {+ workspaceId = idOrSlug.replace("ws_", "");+ } else {+ workspaceSlug = idOrSlug;+ }+ }- if (idOrSlug) {- if (idOrSlug.startsWith("ws_")) {- workspaceId = idOrSlug.replace("ws_", "");+ if (apiKey) {+ const hashedKey = await hashToken(apiKey);+ const prismaArgs = {+ where: {+ hashedKey,+ },+ select: {+ ...(isRestrictedToken && {+ scopes: true,+ rateLimit: true,+ projectId: true,+ }),+ user: {+ select: {+ id: true,+ name: true,+ email: true,+ isMachine: true,+ },+ },+ },+ };++ if (isRestrictedToken) {+ token = await prismaEdge.restrictedToken.findUnique(prismaArgs);+ } else {+ token = await prismaEdge.token.findUnique(prismaArgs);+ }++ if (!token || !token.user) {+ throw new DubApiError({+ code: "unauthorized",+ message: "Unauthorized: Invalid API key.",+ });+ }++ // Rate limit checks for API keys+ const rateLimit = token?.rateLimit || 600;++ const { success, limit, reset, remaining } = await ratelimit(+ rateLimit,+ "1 m",+ ).limit(apiKey);+ headers = {+ "Retry-After": reset.toString(),+ "X-RateLimit-Limit": limit.toString(),+ "X-RateLimit-Remaining": remaining.toString(),+ "X-RateLimit-Reset": reset.toString(),+ };++ if (!success) {+ throw new DubApiError({+ code: "rate_limit_exceeded",+ message: "Too many requests.",+ });+ }++ // Find workspaceId if it's a restricted token+ if (isRestrictedToken) {+ workspaceId = token.projectId;+ }++ waitUntil(+ // update last used time for the token+ (async () => {+ const prismaArgs = {+ where: {+ hashedKey,+ },+ data: {+ lastUsed: new Date(),+ },+ };++ if (isRestrictedToken) {+ await prismaEdge.restrictedToken.update(prismaArgs);+ } else {+ await prismaEdge.token.update(prismaArgs);+ }+ })(),+ );++ session = {+ user: {+ id: token.user.id,+ name: token.user.name || "",+ email: token.user.email || "",+ isMachine: token.user.isMachine,+ },+ };} else {- workspaceSlug = idOrSlug;+ session = (await getToken({+ req: req as NextRequest,+ secret: process.env.NEXTAUTH_SECRET,+ })) as unknown as Session;++ if (!session?.user?.id) {+ throw new DubApiError({+ code: "unauthorized",+ message: "Unauthorized: Login required.",+ });+ }}- }- if (apiKey) {- const hashedKey = await hashToken(apiKey);- const prismaArgs = {+ const workspace = (await prismaEdge.project.findUnique({where: {- hashedKey,+ id: workspaceId || undefined,+ slug: workspaceSlug || undefined,},- select: {- ...(isRestrictedToken && {- scopes: true,- rateLimit: true,- projectId: true,- }),- user: {+ include: {+ users: {+ where: {+ userId: session.user.id,+ },+ select: {+ role: true,+ },+ },+ domains: {select: {id: true,- name: true,- email: true,- isMachine: true,+ slug: true,+ primary: true,+ verified: true,},},},- };+ })) as WorkspaceProps;- if (isRestrictedToken) {- token = await prismaEdge.restrictedToken.findUnique(prismaArgs);- } else {- token = await prismaEdge.token.findUnique(prismaArgs);- }-- if (!token || !token.user) {+ // workspace doesn't exist+ if (!workspace || !workspace.users) {throw new DubApiError({- code: "unauthorized",- message: "Unauthorized: Invalid API key.",+ code: "not_found",+ message: "Workspace not found.",});}- // Rate limit checks for API keys- const rateLimit = token?.rateLimit || 600;-- const { success, limit, reset, remaining } = await ratelimit(- rateLimit,- "1 m",- ).limit(apiKey);- headers = {- "Retry-After": reset.toString(),- "X-RateLimit-Limit": limit.toString(),- "X-RateLimit-Remaining": remaining.toString(),- "X-RateLimit-Reset": reset.toString(),- };-- if (!success) {- throw new DubApiError({- code: "rate_limit_exceeded",- message: "Too many requests.",- });+ // Machine users have owner role by default+ // Only workspace owners can create machine users+ if (session.user.isMachine) {+ workspace.users[0].role = "owner";}- // Find workspaceId if it's a restricted token+ permissions = getPermissionsByRole(workspace.users[0].role);++ // Find the subset of permissions that the user has access to based on the token scopesif (isRestrictedToken) {- workspaceId = token.projectId;+ const tokenScopes: Scope[] = token.scopes.split(" ") || [];+ permissions = mapScopesToPermissions(tokenScopes).filter((p) =>+ permissions.includes(p),+ );}- waitUntil(- // update last used time for the token- (async () => {- const prismaArgs = {- where: {- hashedKey,- },- data: {- lastUsed: new Date(),- },- };-- if (isRestrictedToken) {- await prismaEdge.restrictedToken.update(prismaArgs);- } else {- await prismaEdge.token.update(prismaArgs);- }- })(),- );-- session = {- user: {- id: token.user.id,- name: token.user.name || "",- email: token.user.email || "",- isMachine: token.user.isMachine,- },- };- } else {- session = (await getToken({- req: req as NextRequest,- secret: process.env.NEXTAUTH_SECRET,- })) as unknown as Session;-- if (!session?.user?.id) {- throw new DubApiError({- code: "unauthorized",- message: "Unauthorized: Login required.",- });+ // Check user has permission to make the action+ throwIfNoAccess({+ permissions,+ requiredPermissions,+ workspaceId: workspace.id,+ });++ // beta feature checks+ if (featureFlag) {+ const flags = await getFeatureFlags(workspace.id);++ if (!flags[featureFlag]) {+ throw new DubApiError({+ code: "forbidden",+ message: "Unauthorized: Beta feature.",+ });+ }}- }- const workspace = (await prismaEdge.project.findUnique({- where: {- id: workspaceId || undefined,- slug: workspaceSlug || undefined,- },- include: {- users: {+ // workspace exists but user is not part of it+ if (workspace.users.length === 0) {+ const pendingInvites = await prismaEdge.projectInvite.findUnique({where: {- userId: session.user.id,- },- select: {- role: true,+ email_projectId: {+ email: session.user.email,+ projectId: workspace.id,+ },},- },- domains: {select: {- id: true,- slug: true,- primary: true,- verified: true,+ expires: true,},- },- },- })) as WorkspaceProps;-- // workspace doesn't exist- if (!workspace || !workspace.users) {- throw new DubApiError({- code: "not_found",- message: "Workspace not found.",- });- }-- // Machine users have owner role by default- // Only workspace owners can create machine users- if (session.user.isMachine) {- workspace.users[0].role = "owner";- }-- permissions = getPermissionsByRole(workspace.users[0].role);-- // Find the subset of permissions that the user has access to based on the token scopes- if (isRestrictedToken) {- const tokenScopes: Scope[] = token.scopes.split(" ") || [];- permissions = mapScopesToPermissions(tokenScopes).filter((p) =>- permissions.includes(p),- );- }-- // Check user has permission to make the action- throwIfNoAccess({- permissions,- requiredPermissions,- workspaceId: workspace.id,- });-- // beta feature checks- if (featureFlag) {- const flags = await getFeatureFlags(workspace.id);+ });+ if (!pendingInvites) {+ throw new DubApiError({+ code: "not_found",+ message: "Workspace not found.",+ });+ } else if (pendingInvites.expires < new Date()) {+ throw new DubApiError({+ code: "invite_expired",+ message: "Workspace invite expired.",+ });+ } else {+ throw new DubApiError({+ code: "invite_pending",+ message: "Workspace invite pending.",+ });+ }+ }- if (!flags[featureFlag]) {+ // clicks usage overage checks+ if (needNotExceededClicks && workspace.usage > workspace.usageLimit) {throw new DubApiError({code: "forbidden",- message: "Unauthorized: Beta feature.",+ message: exceededLimitError({+ plan: workspace.plan,+ limit: workspace.usageLimit,+ type: "clicks",+ }),});}- }- // workspace exists but user is not part of it- if (workspace.users.length === 0) {- const pendingInvites = await prismaEdge.projectInvite.findUnique({- where: {- email_projectId: {- email: session.user.email,- projectId: workspace.id,- },- },- select: {- expires: true,- },- });- if (!pendingInvites) {+ // links usage overage checks+ if (+ needNotExceededLinks &&+ workspace.linksUsage > workspace.linksLimit &&+ (workspace.plan === "free" || workspace.plan === "pro")+ ) {throw new DubApiError({- code: "not_found",- message: "Workspace not found.",+ code: "forbidden",+ message: exceededLimitError({+ plan: workspace.plan,+ limit: workspace.linksLimit,+ type: "links",+ }),});- } else if (pendingInvites.expires < new Date()) {+ }++ // AI usage overage checks+ if (needNotExceededAI && workspace.aiUsage > workspace.aiLimit) {throw new DubApiError({- code: "invite_expired",- message: "Workspace invite expired.",+ code: "forbidden",+ message: exceededLimitError({+ plan: workspace.plan,+ limit: workspace.aiLimit,+ type: "AI",+ }),});- } else {+ }++ // plan checks+ if (!requiredPlan.includes(workspace.plan)) {throw new DubApiError({- code: "invite_pending",- message: "Workspace invite pending.",+ code: "forbidden",+ message: "Unauthorized: Need higher plan.",});}- }-- // clicks usage overage checks- if (needNotExceededClicks && workspace.usage > workspace.usageLimit) {- throw new DubApiError({- code: "forbidden",- message: exceededLimitError({- plan: workspace.plan,- limit: workspace.usageLimit,- type: "clicks",- }),- });- }- // links usage overage checks- if (- needNotExceededLinks &&- workspace.linksUsage > workspace.linksLimit &&- (workspace.plan === "free" || workspace.plan === "pro")- ) {- throw new DubApiError({- code: "forbidden",- message: exceededLimitError({- plan: workspace.plan,- limit: workspace.linksLimit,- type: "links",- }),- });- }-- // AI usage overage checks- if (needNotExceededAI && workspace.aiUsage > workspace.aiLimit) {- throw new DubApiError({- code: "forbidden",- message: exceededLimitError({- plan: workspace.plan,- limit: workspace.aiLimit,- type: "AI",- }),- });- }-- // plan checks- if (!requiredPlan.includes(workspace.plan)) {- throw new DubApiError({- code: "forbidden",- message: "Unauthorized: Need higher plan.",- });- }+ // analytics API checks+ const url = new URL(req.url || "", API_DOMAIN);+ if (+ workspace.plan === "free" &&+ apiKey &&+ url.pathname.includes("/analytics")+ ) {+ throw new DubApiError({+ code: "forbidden",+ message: "Analytics API is only available on paid plans.",+ });+ }- // analytics API checks- const url = new URL(req.url || "", API_DOMAIN);- if (- workspace.plan === "free" &&- apiKey &&- url.pathname.includes("/analytics")- ) {- throw new DubApiError({- code: "forbidden",- message: "Analytics API is only available on paid plans.",+ return await handler({+ req,+ params,+ searchParams,+ headers,+ session,+ workspace,+ permissions,});+ } catch (error) {+ req.log.error(error);+ return handleAndReturnErrorResponse(error, headers);}-- return await handler({- req,- params,- searchParams,- headers,- session,- workspace,- permissions,- });- } catch (error) {- return handleAndReturnErrorResponse(error, headers);- }- };+ },+ );};diff --git a/apps/web/lib/auth/workspace.ts b/apps/web/lib/auth/workspace.tsindex be0869c0e7..bb6a152f91 100644--- a/apps/web/lib/auth/workspace.ts+++ b/apps/web/lib/auth/workspace.ts@@ -4,6 +4,7 @@ import { BetaFeatures, PlanProps, WorkspaceWithUsers } from "@/lib/types";import { ratelimit } from "@/lib/upstash";import { API_DOMAIN, getSearchParams } from "@dub/utils";import { waitUntil } from "@vercel/functions";+import { AxiomRequest, withAxiom } from "next-axiom";import { throwIfNoAccess } from "../api/tokens/permissions";import {PermissionAction,@@ -59,298 +60,301 @@ export const withWorkspace = (skipPermissionChecks?: boolean;} = {},) => {- return async (- req: Request,- { params = {} }: { params: Record<string, string> | undefined },- ) => {- const searchParams = getSearchParams(req.url);-- let apiKey: string | undefined = undefined;- let headers = {};-- try {- const authorizationHeader = req.headers.get("Authorization");- if (authorizationHeader) {- if (!authorizationHeader.includes("Bearer ")) {- throw new DubApiError({- code: "bad_request",- message:- "Misconfigured authorization header. Did you forget to add 'Bearer '? Learn more: https://d.to/auth",- });+ return withAxiom(+ async (+ req: AxiomRequest,+ { params = {} }: { params: Record<string, string> | undefined },+ ) => {+ const searchParams = getSearchParams(req.url);++ let apiKey: string | undefined = undefined;+ let headers = {};++ try {+ const authorizationHeader = req.headers.get("Authorization");+ if (authorizationHeader) {+ if (!authorizationHeader.includes("Bearer ")) {+ throw new DubApiError({+ code: "bad_request",+ message:+ "Misconfigured authorization header. Did you forget to add 'Bearer '? Learn more: https://d.to/auth",+ });+ }+ apiKey = authorizationHeader.replace("Bearer ", "");}- apiKey = authorizationHeader.replace("Bearer ", "");- }- let session: Session | undefined;- let workspaceId: string | undefined;- let workspaceSlug: string | undefined;- let permissions: PermissionAction[] = [];- let token: any | null = null;- const isRestrictedToken = apiKey?.startsWith("dub_");-- const idOrSlug =- params?.idOrSlug ||- searchParams.workspaceId ||- params?.slug ||- searchParams.projectSlug;-- // if there's no workspace ID or slug and it's not a restricted token- // For restricted tokens, we find the workspaceId from the token- if (!idOrSlug && !isRestrictedToken) {- // for /api/links (POST /api/links) – allow no session (but warn if user provides apiKey)- if (allowAnonymous && !apiKey) {- // @ts-expect-error- return await handler({- req,- params,- searchParams,- headers,- });- } else {- throw new DubApiError({- code: "not_found",- message:- "Workspace id not found. Did you forget to include a `workspaceId` query parameter? Learn more: https://d.to/id",- });+ let session: Session | undefined;+ let workspaceId: string | undefined;+ let workspaceSlug: string | undefined;+ let permissions: PermissionAction[] = [];+ let token: any | null = null;+ const isRestrictedToken = apiKey?.startsWith("dub_");++ const idOrSlug =+ params?.idOrSlug ||+ searchParams.workspaceId ||+ params?.slug ||+ searchParams.projectSlug;++ // if there's no workspace ID or slug and it's not a restricted token+ // For restricted tokens, we find the workspaceId from the token+ if (!idOrSlug && !isRestrictedToken) {+ // for /api/links (POST /api/links) – allow no session (but warn if user provides apiKey)+ if (allowAnonymous && !apiKey) {+ // @ts-expect-error+ return await handler({+ req,+ params,+ searchParams,+ headers,+ });+ } else {+ throw new DubApiError({+ code: "not_found",+ message:+ "Workspace id not found. Did you forget to include a `workspaceId` query parameter? Learn more: https://d.to/id",+ });+ }}- }- if (idOrSlug) {- if (idOrSlug.startsWith("ws_")) {- workspaceId = idOrSlug.replace("ws_", "");- } else {- workspaceSlug = idOrSlug;+ if (idOrSlug) {+ if (idOrSlug.startsWith("ws_")) {+ workspaceId = idOrSlug.replace("ws_", "");+ } else {+ workspaceSlug = idOrSlug;+ }}- }- if (apiKey) {- const hashedKey = await hashToken(apiKey);- const prismaArgs = {- where: {- hashedKey,- },- select: {- ...(isRestrictedToken && {- scopes: true,- rateLimit: true,- projectId: true,- }),- user: {- select: {- id: true,- name: true,- email: true,- isMachine: true,+ if (apiKey) {+ const hashedKey = await hashToken(apiKey);+ const prismaArgs = {+ where: {+ hashedKey,+ },+ select: {+ ...(isRestrictedToken && {+ scopes: true,+ rateLimit: true,+ projectId: true,+ }),+ user: {+ select: {+ id: true,+ name: true,+ email: true,+ isMachine: true,+ },},},- },- };-- if (isRestrictedToken) {- token = await prisma.restrictedToken.findUnique(prismaArgs);+ };++ if (isRestrictedToken) {+ token = await prisma.restrictedToken.findUnique(prismaArgs);+ } else {+ token = await prisma.token.findUnique(prismaArgs);+ }++ if (!token || !token.user) {+ throw new DubApiError({+ code: "unauthorized",+ message: "Unauthorized: Invalid API key.",+ });+ }++ // Rate limit checks for API keys+ const rateLimit = token.rateLimit || 600;++ const { success, limit, reset, remaining } = await ratelimit(+ rateLimit,+ "1 m",+ ).limit(apiKey);++ headers = {+ "Retry-After": reset.toString(),+ "X-RateLimit-Limit": limit.toString(),+ "X-RateLimit-Remaining": remaining.toString(),+ "X-RateLimit-Reset": reset.toString(),+ };++ if (!success) {+ throw new DubApiError({+ code: "rate_limit_exceeded",+ message: "Too many requests.",+ });+ }++ // Find workspaceId if it's a restricted token+ if (isRestrictedToken) {+ workspaceId = token.projectId;+ }++ waitUntil(+ // update last used time for the token+ (async () => {+ const prismaArgs = {+ where: {+ hashedKey,+ },+ data: {+ lastUsed: new Date(),+ },+ };++ if (isRestrictedToken) {+ await prisma.restrictedToken.update(prismaArgs);+ } else {+ await prisma.token.update(prismaArgs);+ }+ })(),+ );++ session = {+ user: {+ id: token.user.id,+ name: token.user.name || "",+ email: token.user.email || "",+ isMachine: token.user.isMachine,+ },+ };} else {- token = await prisma.token.findUnique(prismaArgs);- }-- if (!token || !token.user) {- throw new DubApiError({- code: "unauthorized",- message: "Unauthorized: Invalid API key.",- });+ session = await getSession();++ if (!session?.user?.id) {+ throw new DubApiError({+ code: "unauthorized",+ message: "Unauthorized: Login required.",+ });+ }}- // Rate limit checks for API keys- const rateLimit = token.rateLimit || 600;-- const { success, limit, reset, remaining } = await ratelimit(- rateLimit,- "1 m",- ).limit(apiKey);-- headers = {- "Retry-After": reset.toString(),- "X-RateLimit-Limit": limit.toString(),- "X-RateLimit-Remaining": remaining.toString(),- "X-RateLimit-Reset": reset.toString(),- };-- if (!success) {- throw new DubApiError({- code: "rate_limit_exceeded",- message: "Too many requests.",- });- }-- // Find workspaceId if it's a restricted token- if (isRestrictedToken) {- workspaceId = token.projectId;- }-- waitUntil(- // update last used time for the token- (async () => {- const prismaArgs = {+ const workspace = (await prisma.project.findUnique({+ where: {+ id: workspaceId || undefined,+ slug: workspaceSlug || undefined,+ },+ include: {+ users: {where: {- hashedKey,+ userId: session.user.id,},- data: {- lastUsed: new Date(),+ select: {+ role: true,},- };-- if (isRestrictedToken) {- await prisma.restrictedToken.update(prismaArgs);- } else {- await prisma.token.update(prismaArgs);- }- })(),- );-- session = {- user: {- id: token.user.id,- name: token.user.name || "",- email: token.user.email || "",- isMachine: token.user.isMachine,+ },},- };- } else {- session = await getSession();+ })) as WorkspaceWithUsers;- if (!session?.user?.id) {+ // workspace doesn't exist+ if (!workspace || !workspace.users) {throw new DubApiError({- code: "unauthorized",- message: "Unauthorized: Login required.",+ code: "not_found",+ message: "Workspace not found.",});}- }- const workspace = (await prisma.project.findUnique({- where: {- id: workspaceId || undefined,- slug: workspaceSlug || undefined,- },- include: {- users: {+ // workspace exists but user is not part of it+ if (workspace.users.length === 0) {+ const pendingInvites = await prisma.projectInvite.findUnique({where: {- userId: session.user.id,+ email_projectId: {+ email: session.user.email,+ projectId: workspace.id,+ },},select: {- role: true,+ expires: true,},- },- },- })) as WorkspaceWithUsers;-- // workspace doesn't exist- if (!workspace || !workspace.users) {- throw new DubApiError({- code: "not_found",- message: "Workspace not found.",- });- }+ });- // workspace exists but user is not part of it- if (workspace.users.length === 0) {- const pendingInvites = await prisma.projectInvite.findUnique({- where: {- email_projectId: {- email: session.user.email,- projectId: workspace.id,- },- },- select: {- expires: true,- },- });+ if (!pendingInvites) {+ throw new DubApiError({+ code: "not_found",+ message: "Workspace not found.",+ });+ } else if (pendingInvites.expires < new Date()) {+ throw new DubApiError({+ code: "invite_expired",+ message: "Workspace invite expired.",+ });+ } else {+ throw new DubApiError({+ code: "invite_pending",+ message: "Workspace invite pending.",+ });+ }+ }- if (!pendingInvites) {- throw new DubApiError({- code: "not_found",- message: "Workspace not found.",- });- } else if (pendingInvites.expires < new Date()) {- throw new DubApiError({- code: "invite_expired",- message: "Workspace invite expired.",- });- } else {- throw new DubApiError({- code: "invite_pending",- message: "Workspace invite pending.",- });+ // Machine users have owner role by default+ // Only workspace owners can create machine users+ if (session.user.isMachine) {+ workspace.users[0].role = "owner";}- }- // Machine users have owner role by default- // Only workspace owners can create machine users- if (session.user.isMachine) {- workspace.users[0].role = "owner";- }+ permissions = getPermissionsByRole(workspace.users[0].role);- permissions = getPermissionsByRole(workspace.users[0].role);+ // Find the subset of permissions that the user has access to based on the token scopes+ if (isRestrictedToken) {+ const tokenScopes: Scope[] = token.scopes.split(" ") || [];+ permissions = mapScopesToPermissions(tokenScopes).filter((p) =>+ permissions.includes(p),+ );+ }- // Find the subset of permissions that the user has access to based on the token scopes- if (isRestrictedToken) {- const tokenScopes: Scope[] = token.scopes.split(" ") || [];- permissions = mapScopesToPermissions(tokenScopes).filter((p) =>- permissions.includes(p),- );- }+ // Check user has permission to make the action+ if (!skipPermissionChecks) {+ throwIfNoAccess({+ permissions,+ requiredPermissions,+ workspaceId: workspace.id,+ });+ }- // Check user has permission to make the action- if (!skipPermissionChecks) {- throwIfNoAccess({- permissions,- requiredPermissions,- workspaceId: workspace.id,- });- }+ // beta feature checks+ if (featureFlag) {+ const flags = await getFeatureFlags(workspace.id);- // beta feature checks- if (featureFlag) {- const flags = await getFeatureFlags(workspace.id);+ if (!flags[featureFlag]) {+ throw new DubApiError({+ code: "forbidden",+ message: "Unauthorized: Beta feature.",+ });+ }+ }- if (!flags[featureFlag]) {+ // plan checks+ if (!requiredPlan.includes(workspace.plan)) {throw new DubApiError({code: "forbidden",- message: "Unauthorized: Beta feature.",+ message: "Unauthorized: Need higher plan.",});}- }- // plan checks- if (!requiredPlan.includes(workspace.plan)) {- throw new DubApiError({- code: "forbidden",- message: "Unauthorized: Need higher plan.",- });- }+ // analytics API checks+ const url = new URL(req.url || "", API_DOMAIN);+ if (+ workspace.plan === "free" &&+ apiKey &&+ url.pathname.includes("/analytics")+ ) {+ throw new DubApiError({+ code: "forbidden",+ message: "Analytics API is only available on paid plans.",+ });+ }- // analytics API checks- const url = new URL(req.url || "", API_DOMAIN);- if (- workspace.plan === "free" &&- apiKey &&- url.pathname.includes("/analytics")- ) {- throw new DubApiError({- code: "forbidden",- message: "Analytics API is only available on paid plans.",+ return await handler({+ req,+ params,+ searchParams,+ headers,+ session,+ workspace,+ permissions,});+ } catch (error) {+ req.log.error(error);+ return handleAndReturnErrorResponse(error, headers);}-- return await handler({- req,- params,- searchParams,- headers,- session,- workspace,- permissions,- });- } catch (error) {- return handleAndReturnErrorResponse(error, headers);- }- };+ },+ );};diff --git a/apps/web/lib/middleware/axiom.ts b/apps/web/lib/middleware/axiom.tsnew file mode 100644index 0000000000..83e184226c--- /dev/null+++ b/apps/web/lib/middleware/axiom.ts@@ -0,0 +1,8 @@+import { Logger } from "next-axiom";+import { NextFetchEvent, NextRequest } from "next/server";++export default function AxiomMiddleware(req: NextRequest, ev: NextFetchEvent) {+ const logger = new Logger({ source: "middleware" }); // traffic, request+ logger.middleware(req);+ ev.waitUntil(logger.flush());+}diff --git a/apps/web/middleware.ts b/apps/web/middleware.tsindex 805ba03a74..4a01a8b38c 100644--- a/apps/web/middleware.ts+++ b/apps/web/middleware.ts@@ -9,6 +9,7 @@ import {} from "@dub/utils";import { NextFetchEvent, NextRequest, NextResponse } from "next/server";import AdminMiddleware from "./lib/middleware/admin";+import AxiomMiddleware from "./lib/middleware/axiom";import CreateLinkMiddleware from "./lib/middleware/create-link";export const config = {@@ -29,6 +30,8 @@ export const config = {export default async function middleware(req: NextRequest, ev: NextFetchEvent) {const { domain, path, key, fullKey } = parse(req);+ AxiomMiddleware(req, ev);+// for Appif (APP_HOSTNAMES.has(domain)) {return AppMiddleware(req);diff --git a/apps/web/next.config.js b/apps/web/next.config.jsindex 7525bf6d1a..d59318eb8e 100644--- a/apps/web/next.config.js+++ b/apps/web/next.config.js@@ -7,8 +7,10 @@ const REDIRECT_SEGMENTS = ["_static",];+const { withAxiom } = require("next-axiom");+/** @type {import('next').NextConfig} */-module.exports = {+module.exports = withAxiom({reactStrictMode: false,experimental: {serverComponentsExternalPackages: [@@ -206,4 +208,4 @@ module.exports = {},];},-};+});diff --git a/apps/web/package.json b/apps/web/package.jsonindex b8485577b6..2e2e9ff7c1 100644--- a/apps/web/package.json+++ b/apps/web/package.json@@ -74,6 +74,7 @@"nanoid": "^5.0.1","next": "14.3.0-canary.42","next-auth": "^4.24.4",+ "next-axiom": "^1.3.0","node-html-parser": "^6.1.4","nodemailer": "^6.9.3","openapi-types": "^12.1.3",diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex e78019eeda..f85c1c7402 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -218,6 +218,9 @@ importers:next-auth:specifier: ^4.24.4+ next-axiom:+ specifier: ^1.3.0node-html-parser:specifier: ^6.1.4version: 6.1.4@@ -2970,7 +2973,6 @@ packages:cpu: [ppc64]os: [aix]requiresBuild: true- dev: trueoptional: true/@esbuild/[email protected]:@@ -2997,7 +2999,6 @@ packages:cpu: [arm64]os: [android]requiresBuild: true- dev: trueoptional: true/@esbuild/[email protected]:@@ -3024,7 +3025,6 @@ packages:cpu: [arm]os: [android]requiresBuild: true- dev: trueoptional: true/@esbuild/[email protected]:@@ -3051,7 +3051,6 @@ packages:cpu: [x64]os: [android]requiresBuild: true- dev: trueoptional: true/@esbuild/[email protected]:@@ -3078,7 +3077,6 @@ packages:cpu: [arm64]os: [darwin]requiresBuild: true- dev: trueoptional: true/@esbuild/[email protected]:@@ -3105,7 +3103,6 @@ packages:cpu: [x64]os: [darwin]requiresBuild: true- dev: trueoptional: true/@esbuild/[email protected]:@@ -3132,7 +3129,6 @@ packages:cpu: [arm64]os: [freebsd]requiresBuild: true- dev: trueoptional: true/@esbuild/[email protected]:@@ -3159,7 +3155,6 @@ packages:cpu: [x64]os: [freebsd]requiresBuild: true- dev: trueoptional: true/@esbuild/[email protected]:@@ -3186,7 +3181,6 @@ packages:cpu: [arm64]os: [linux]requiresBuild: true- dev: trueoptional: true/@esbuild/[email protected]:@@ -3213,7 +3207,6 @@ packages:cpu: [arm]os: [linux]requiresBuild: true- dev: trueoptional: true/@esbuild/[email protected]:@@ -3240,7 +3233,6 @@ packages:cpu: [ia32]os: [linux]requiresBuild: true- dev: trueoptional: true/@esbuild/[email protected]:@@ -3276,7 +3268,6 @@ packages:cpu: [loong64]os: [linux]requiresBuild: true- dev: trueoptional: true/@esbuild/[email protected]:@@ -3303,7 +3294,6 @@ packages:cpu: [mips64el]os: [linux]requiresBuild: true- dev: trueoptional: true/@esbuild/[email protected]:@@ -3330,7 +3320,6 @@ packages:cpu: [ppc64]os: [linux]requiresBuild: true- dev: trueoptional: true/@esbuild/[email protected]:@@ -3357,7 +3346,6 @@ packages:cpu: [riscv64]os: [linux]requiresBuild: true- dev: trueoptional: true/@esbuild/[email protected]:@@ -3384,7 +3372,6 @@ packages:cpu: [s390x]os: [linux]requiresBuild: true- dev: trueoptional: true/@esbuild/[email protected]:@@ -3411,7 +3398,6 @@ packages:cpu: [x64]os: [linux]requiresBuild: true- dev: trueoptional: true/@esbuild/[email protected]:@@ -3438,7 +3424,6 @@ packages:cpu: [x64]os: [netbsd]requiresBuild: true- dev: trueoptional: true/@esbuild/[email protected]:@@ -3465,7 +3450,6 @@ packages:cpu: [x64]os: [openbsd]requiresBuild: true- dev: trueoptional: true/@esbuild/[email protected]:@@ -3492,7 +3476,6 @@ packages:cpu: [x64]os: [sunos]requiresBuild: true- dev: trueoptional: true/@esbuild/[email protected]:@@ -3519,7 +3502,6 @@ packages:cpu: [arm64]os: [win32]requiresBuild: true- dev: trueoptional: true/@esbuild/[email protected]:@@ -3546,7 +3528,6 @@ packages:cpu: [ia32]os: [win32]requiresBuild: true- dev: trueoptional: true/@esbuild/[email protected]:@@ -3573,7 +3554,6 @@ packages:cpu: [x64]os: [win32]requiresBuild: true- dev: trueoptional: true/@eslint-community/[email protected]([email protected]):@@ -7026,7 +7006,6 @@ packages:cpu: [arm]os: [android]requiresBuild: true- dev: trueoptional: true/@rollup/[email protected]:@@ -7034,7 +7013,6 @@ packages:cpu: [arm64]os: [android]requiresBuild: true- dev: trueoptional: true/@rollup/[email protected]:@@ -7042,7 +7020,6 @@ packages:cpu: [arm64]os: [darwin]requiresBuild: true- dev: trueoptional: true/@rollup/[email protected]:@@ -7050,7 +7027,6 @@ packages:cpu: [x64]os: [darwin]requiresBuild: true- dev: trueoptional: true/@rollup/[email protected]:@@ -7058,7 +7034,6 @@ packages:cpu: [arm]os: [linux]requiresBuild: true- dev: trueoptional: true/@rollup/[email protected]:@@ -7066,7 +7041,6 @@ packages:cpu: [arm64]os: [linux]requiresBuild: true- dev: trueoptional: true/@rollup/[email protected]:@@ -7074,7 +7048,6 @@ packages:cpu: [arm64]os: [linux]requiresBuild: true- dev: trueoptional: true/@rollup/[email protected]:@@ -7082,7 +7055,6 @@ packages:cpu: [ppc64le]os: [linux]requiresBuild: true- dev: trueoptional: true/@rollup/[email protected]:@@ -7090,7 +7062,6 @@ packages:cpu: [riscv64]os: [linux]requiresBuild: true- dev: trueoptional: true/@rollup/[email protected]:@@ -7098,7 +7069,6 @@ packages:cpu: [s390x]os: [linux]requiresBuild: true- dev: trueoptional: true/@rollup/[email protected]:@@ -7106,7 +7076,6 @@ packages:cpu: [x64]os: [linux]requiresBuild: true- dev: trueoptional: true/@rollup/[email protected]:@@ -7114,7 +7083,6 @@ packages:cpu: [x64]os: [linux]requiresBuild: true- dev: trueoptional: true/@rollup/[email protected]:@@ -7122,7 +7090,6 @@ packages:cpu: [arm64]os: [win32]requiresBuild: true- dev: trueoptional: true/@rollup/[email protected]:@@ -7130,7 +7097,6 @@ packages:cpu: [ia32]os: [win32]requiresBuild: true- dev: trueoptional: true/@rollup/[email protected]:@@ -7138,7 +7104,6 @@ packages:cpu: [x64]os: [win32]requiresBuild: true- dev: trueoptional: true/@selderee/[email protected]:@@ -8702,7 +8667,6 @@ packages:'@vitest/spy': 1.5.0'@vitest/utils': 1.5.0chai: 4.4.1- dev: true/@vitest/[email protected]:resolution: {integrity: sha512-7HWwdxXP5yDoe7DTpbif9l6ZmDwCzcSIK38kTSIt6CFEpMjX4EpCgT6wUmS0xTXqMI6E/ONmfgRKmaujpabjZQ==}@@ -8710,7 +8674,6 @@ packages:'@vitest/utils': 1.5.0p-limit: 5.0.0pathe: 1.1.2- dev: true/@vitest/[email protected]:resolution: {integrity: sha512-qpv3fSEuNrhAO3FpH6YYRdaECnnRjg9VxbhdtPwPRnzSfHVXnNzzrpX4cJxqiwgRMo7uRMWDFBlsBq4Cr+rO3A==}@@ -8718,13 +8681,11 @@ packages:magic-string: 0.30.9pathe: 1.1.2pretty-format: 29.7.0- dev: true/@vitest/[email protected]:resolution: {integrity: sha512-vu6vi6ew5N5MMHJjD5PoakMRKYdmIrNJmyfkhRpQt5d9Ewhw9nZ5Aqynbi3N61bvk9UvZ5UysMT6ayIrZ8GA9w==}dependencies:tinyspy: 2.2.1- dev: true/@vitest/[email protected]:resolution: {integrity: sha512-BDU0GNL8MWkRkSRdNFvCUCAVOeHaUlVJ9Tx0TYBZyXaaOTmGtUFObzchCivIBrIwKzvZA7A9sCejVhXM2aY98A==}@@ -8733,7 +8694,6 @@ packages:estree-walker: 3.0.3loupe: 2.3.7pretty-format: 29.7.0- dev: true/@vue/[email protected]:resolution: {integrity: sha512-MjXawxZf2SbZszLPYxaFCjxfibYrzr3eYbKxwpLR9EQN+oaziSu3qKVbwBERj1IFIB8OLUewxB5m/BFzi613og==}@@ -8987,7 +8947,6 @@ packages:resolution: {integrity: sha512-cjkyv4OtNCIeqhHrfS81QWXoCBPExR/J62oyEqepVw8WaQeSqpW2uhuLPh1m9eWhDuOo/jUXVTlifvesOWp/4A==}engines: {node: '>=0.4.0'}- dev: trueresolution: {integrity: sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==}@@ -9347,7 +9306,6 @@ packages:resolution: {integrity: sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==}- dev: trueresolution: {integrity: sha512-c27loCv9QkZinsa5ProX751khO9DJl/AcB5c2KNtA6NRvHKS0PgLfcftz72KVq504vB0Gku5s2kUZzDBvQWvHg==}@@ -9772,7 +9730,6 @@ packages:resolution: {integrity: sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==}engines: {node: '>=8'}- dev: trueresolution: {integrity: sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==}@@ -9861,7 +9818,6 @@ packages:loupe: 2.3.7pathval: 1.1.1type-detect: 4.0.8- dev: trueresolution: {integrity: sha512-U3lRVLMSlsCfjqYPbLyVv11M9CPW4I728d6TCKMAOJueEeB9/8o+eSsMnxPJD+Q+K909sdESg7C+tIkoH6on1A==}@@ -9907,7 +9863,6 @@ packages:resolution: {integrity: sha512-iKEoDYaRmd1mxM90a2OEfWhjsjPpYPuQ+lMYsoxB126+t8fw7ySEO48nmDg5COTjxDI65/Y2OWpeEHk3ZOe8zg==}dependencies:get-func-name: 2.0.2- dev: trueresolution: {integrity: sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==}@@ -10613,7 +10568,6 @@ packages:engines: {node: '>=6'}dependencies:type-detect: 4.0.8- dev: trueresolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==}@@ -10741,7 +10695,6 @@ packages:resolution: {integrity: sha512-EjePK1srD3P08o2j4f0ExnylqRs5B9tJjcp9t1krH2qRi8CCdsYfwe9JgSLurFBWwq4uOlipzfk5fHNvwFKr8Q==}engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}- dev: trueresolution: {integrity: sha512-D+mk+qE8VC/PAUrlAU34N+VfXev0ghe5ywmpqrawphmVZc1bEfn56uo9qpyGp1p4xpzOHkSW4ztBd6L7Xx4ACw==}@@ -11454,7 +11407,6 @@ packages:'@esbuild/win32-arm64': 0.20.2'@esbuild/win32-ia32': 0.20.2'@esbuild/win32-x64': 0.20.2- dev: trueresolution: {integrity: sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==}@@ -11712,7 +11664,6 @@ packages:onetime: 6.0.0signal-exit: 4.1.0strip-final-newline: 3.0.0- dev: trueresolution: {integrity: sha512-Zk/eNKV2zbjpKzrsQ+n1G6poVbErQxJ0LBOJXaKZ1EViLzH+hrLu9cdXI4zw9dBQJslwBEpbQ2P1oS7nDxs6jQ==}@@ -12063,7 +12014,6 @@ packages:resolution: {integrity: sha512-8vXOvuE167CtIc3OyItco7N/dpRtBbYOsPsXCz7X/PMnlGjYjSGuZJgM1Y7mmew7BKf9BqvLX2tnOVy1BBUsxQ==}- dev: trueresolution: {integrity: sha512-2DcsyfABl+gVHEfCOaTrWgyt+tb6MSEGmKq+kI5HwLbIYgjgmMcV8KQ41uaKz1xxUcn9tJtgFbQUEVcEbd0FYw==}@@ -12101,7 +12051,6 @@ packages:resolution: {integrity: sha512-VaUJspBffn/LMCJVoMvSAdmscJyS1auj5Zulnn5UoYcY531UWmdwhRWkcGKnGU93m5HSXP9LP2usOryrBtQowA==}engines: {node: '>=16'}- dev: trueresolution: {integrity: sha512-2EmdH1YvIQiZpltCNgkuiUnyukzxM/R6NDJX31Ke3BG1Nq5b0S2PhX59UKi9vZpPDQVdqn+1IcaAwnzTT5vCjw==}@@ -12536,7 +12485,6 @@ packages:resolution: {integrity: sha512-AXcZb6vzzrFAUE61HnN4mpLqd/cSIwNQjtNWR0euPm6y0iqx3G4gOXaIDdtdDwZmhwe82LA6+zinmW4UBWVePQ==}engines: {node: '>=16.17.0'}- dev: trueresolution: {integrity: sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ==}@@ -12903,7 +12851,6 @@ packages:resolution: {integrity: sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA==}engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}- dev: trueresolution: {integrity: sha512-tE2UXzivje6ofPW7l23cjDOMa09gb7xlAqG6jG5ej6uPV32TlWP3NKPigtaGeHNu9fohccRYvIiZMfOOnOYUtg==}@@ -13722,7 +13669,6 @@ packages:resolution: {integrity: sha512-WriZw1luRMlmV3LGJaR6QOJjWwgLUTf89OwT2lUOyjX2dJGBwgmIkbcz+7WFZjrZM635JOIR517++e/67CP9dQ==}- dev: trueresolution: {integrity: sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==}@@ -14046,7 +13992,6 @@ packages:dependencies:mlly: 1.6.1pkg-types: 1.0.3- dev: trueresolution: {integrity: sha512-SW13ws7BjaeJ6p7Q6CO2nchbYEc3X3J6WrmTTDto7yMPqVSZTUyY5Tjbid+Ab8gLnATtygYtiDIJGQRRn2ZOiA==}@@ -14165,7 +14110,6 @@ packages:resolution: {integrity: sha512-zSMINGVYkdpYSOBmLi0D1Uo7JU9nVdQKrHxC8eYlV+9YKK9WePqAlL7lSlorG/U2Fw1w0hTBmaa/jrQ3UbPHtA==}dependencies:get-func-name: 2.0.2- dev: trueresolution: {integrity: sha512-2bIM8x+VAf6JT4bKAljS1qUWgMsqZRPGJS6FSahIMPVvctcNhyVp7AJu7quxOW9jwkryBReKZY5tY5JYv2n/7Q==}@@ -14990,7 +14934,6 @@ packages:resolution: {integrity: sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==}engines: {node: '>=12'}- dev: trueresolution: {integrity: sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==}@@ -15061,7 +15004,6 @@ packages:pathe: 1.1.2pkg-types: 1.0.3ufo: 1.5.3- dev: trueresolution: {integrity: sha512-2K9QYubXx/NAjv4VLq1d1Ly8pWNC5L3BrixtdkyTegXWJIqY+zLNDhhX/A+ZwWt70tB1S8H4BE8FLYEFyNoOBw==}@@ -15230,6 +15172,34 @@ packages:uuid: 8.3.2dev: false+ resolution: {integrity: sha512-G6e85+LkV9VXIFqil47ozfQH6TORg93kRVkvjFB0IU3h0qpPGgzgfBB7uKU2qmhNgOF4Ub5o44MNYP/8GXHnOw==}+ engines: {node: '>=18'}+ peerDependencies:+ next: '>=13.4'+ react: '>=18.0.0'+ dependencies:+ next: 14.3.0-canary.42(@babel/[email protected])(@opentelemetry/[email protected])([email protected])([email protected])+ react: 18.2.0+ remeda: 1.61.0+ vitest: 1.5.0(@types/[email protected])+ whatwg-fetch: 3.6.19+ transitivePeerDependencies:+ - '@edge-runtime/vm'+ - '@types/node'+ - '@vitest/browser'+ - '@vitest/ui'+ - happy-dom+ - jsdom+ - less+ - lightningcss+ - sass+ - stylus+ - sugarss+ - supports-color+ - terser+ dev: false+/[email protected](@babel/[email protected])(@opentelemetry/[email protected])([email protected])([email protected]):resolution: {integrity: sha512-u8yiAK7L+fl/U9yFmq3VOpkHlImx5wg3OoDz3qxTXhPmmMzNcPbblWgxBf5d6Z+aik8BEn27L31k/tXCRzwFxA==}engines: {node: '>=18.17.0'}@@ -15453,7 +15423,6 @@ packages:engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}dependencies:path-key: 4.0.0- dev: trueresolution: {integrity: sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w==}@@ -15607,7 +15576,6 @@ packages:engines: {node: '>=12'}dependencies:mimic-fn: 4.0.0- dev: trueresolution: {integrity: sha512-IFenVPgF70fSm1keSd2iDBIDIBZkroLeuffXq+wKTzTJlBpesFWojV9lb8mzOfaAzM1sr7HQHuO0vtV0zYekGg==}@@ -15696,7 +15664,6 @@ packages:engines: {node: '>=18'}dependencies:yocto-queue: 1.0.0- dev: trueresolution: {integrity: sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==}@@ -15812,7 +15779,6 @@ packages:resolution: {integrity: sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ==}engines: {node: '>=12'}- dev: trueresolution: {integrity: sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==}@@ -15840,11 +15806,9 @@ packages:resolution: {integrity: sha512-whLdWMYL2TwI08hn8/ZqAbrVemu0LNaNNJZX73O6qaIdCTfXutsLhMkjdENX0qhsQ9uIimo4/aQOmXkoon2nDQ==}- dev: trueresolution: {integrity: sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==}- dev: trueresolution: {integrity: sha512-XIxfHpEuSJbITd1H3EeQwpcZbTLHc+VVr8ANI9t5sit565tsI4/xK3KWTUFE2e6QiangUkh3B0jihzmGnNrRsQ==}@@ -15964,7 +15928,6 @@ packages:jsonc-parser: 3.2.0mlly: 1.6.1pathe: 1.1.2- dev: trueresolution: {integrity: sha512-d7Uw+eZoloe0EHDIYoe+bQ5WXnGMOpmiZFTuMWCwpjzzkL2nTjcKiAk4hh8TjnGye2TwWOk3UXucZ+3rbmBa8Q==}@@ -17072,6 +17035,10 @@ packages:- supports-colordev: false+ resolution: {integrity: sha512-caKfSz9rDeSKBQQnlJnVW3mbVdFgxgGWQKq1XlFokqjf+hQD5gxutLGTTY2A/x24UxVyJe9gH5fAkFI63ULw4A==}+ dev: false+resolution: {integrity: sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==}engines: {node: '>=0.10.0'}@@ -17212,7 +17179,6 @@ packages:'@rollup/rollup-win32-ia32-msvc': 4.14.0'@rollup/rollup-win32-x64-msvc': 4.14.0fsevents: 2.3.3- dev: trueresolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==}@@ -17588,7 +17554,6 @@ packages:resolution: {integrity: sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==}- dev: trueresolution: {integrity: sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==}@@ -17818,7 +17783,6 @@ packages:resolution: {integrity: sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==}- dev: trueresolution: {integrity: sha512-oeVtt7eWQS+Na6F//S4kJ2K2VbRlS9D43mAlMyVpVWovy9o+jfgH8O9agzANzaiLjclA0oYzUXEM4PurhSUChw==}@@ -17843,7 +17807,6 @@ packages:resolution: {integrity: sha512-JPbdCEQLj1w5GilpiHAx3qJvFndqybBysA3qUOnznweH4QbNYUsW/ea8QzSrnh0vNsezMMw5bcVool8lM0gwzg==}- dev: trueresolution: {integrity: sha512-KXDYZ9dszj6bzvnEMRYvxgeTHU74QBFL54XKtP3nyMuJ81CFYtABZ3bAzL2EdFUaEwJOBOgENyFj3R7oTzDyyw==}@@ -18012,7 +17975,6 @@ packages:resolution: {integrity: sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==}engines: {node: '>=12'}- dev: trueresolution: {integrity: sha512-laJTa3Jb+VQpaC6DseHhF7dXVqHTfJPCRDaEbid/drOhgitgYku/letMUqOXFoWV0zIIUbjpdH2t+tYj4bQMRQ==}@@ -18029,7 +17991,6 @@ packages:resolution: {integrity: sha512-Op+UycaUt/8FbN/Z2TWPBLge3jWrP3xj10f3fnYxf052bKuS3EKs1ZQcVGjnEMdsNVAM+plXRdmjrZ/KgG3Skw==}dependencies:js-tokens: 9.0.0- dev: trueresolution: {integrity: sha512-aM9xfyDryiaf/qSWMtJaTMrlc/he3qyx3aVHMqOZqUiMdgTV6lt7tLpFrU0pG+QURm1LAP9GYZ+EcA17446YoQ==}@@ -18408,17 +18369,14 @@ packages:resolution: {integrity: sha512-N8hW3PG/3aOoZAN5V/NSAEDz0ZixDSSt5b/a05iqtpgfLWMSVuCo7w0k2vVvEjdrIoeGqZzweX2WlyioNIHchA==}- dev: trueresolution: {integrity: sha512-Ud7uepAklqRH1bvwy22ynrliC7Dljz7Tm8M/0RBUW+YRa4YHhZ6e4PpgE+fu1zr/WqB1kbeuVrdfeuyIBpy4tw==}engines: {node: '>=14.0.0'}- dev: trueresolution: {integrity: sha512-KYad6Vy5VDWV4GH3fjpseMQ/XU2BhIYP7Vzd0LG44qRWm/Yt2WCOTicFdvmgo6gWaqooMQCawTtILVQJupKu7A==}engines: {node: '>=14.0.0'}- dev: trueresolution: {integrity: sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw==}@@ -18969,7 +18927,6 @@ packages:resolution: {integrity: sha512-Y7HYmWaFwPUmkoQCUIAYpKqkOf+SbVj/2fJJZ4RJMCfZp0rTGwRbzQD+HghfnhKOjL9E01okqz+ncJskGYfBNw==}- dev: trueresolution: {integrity: sha512-r+MU0rfv4L/0eeW3xZrd16t4NZfK8Ld4SWVglYBb7ez5uXFWHuVRs6xCTrf1yirs9a4j4Y27nn7SRfO6v67XsQ==}@@ -19312,7 +19269,6 @@ packages:- sugarss- supports-color- terser- dev: trueresolution: {integrity: sha512-0Vd/a6po6Q+86rPlntHye7F31zA2URZMbH8M3saAZ/xR9QoGN/L21bxEGfXdWmFdNkqPpRdxFT7nmNe12e9/uA==}@@ -19365,7 +19321,6 @@ packages:rollup: 4.14.0optionalDependencies:fsevents: 2.3.3- dev: true/[email protected](@types/[email protected]):resolution: {integrity: sha512-d8UKgR0m2kjdxDWX6911uwxout6GHS0XaGH1cksSIVVG8kRlE7G7aBw7myKQCvDI5dT4j7ZMa+l706BIORMDLw==}@@ -19421,7 +19376,6 @@ packages:- sugarss- supports-color- terser- dev: trueresolution: {integrity: sha512-gQpnTgkubC6hQgdIcRdYGDSDc+SaujOdyesZQMv6JlfQee/9Mp0Qhnys6WxDWvQnL5WZdT7o2Ul187aSt0Rq+w==}@@ -19684,7 +19638,6 @@ packages:dependencies:siginfo: 2.0.0stackback: 0.0.2- dev: trueresolution: {integrity: sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==}@@ -19924,7 +19877,6 @@ packages:resolution: {integrity: sha512-9bnSc/HEW2uRy67wc+T8UwauLuPJVn28jb+GtJY16iiKWyvmYJRXVT4UamsAEGQfPohgr2q4Tq0sQbQlxTfi1g==}engines: {node: '>=12.20'}- dev: trueresolution: {integrity: sha512-N+d4UJSJbt/R3wqY7Coqs5pcV0aUj2j9IaQ3rNj9bVCLld8tTGKRa2USARjnvZJWVx1NDmQev8EknoczaOQDOA==}