diff --git a/app/api/rpc/[command]/domain_routes.ts b/app/api/rpc/[command]/domain_routes.ts index ca063a54..5781fa2a 100644 --- a/app/api/rpc/[command]/domain_routes.ts +++ b/app/api/rpc/[command]/domain_routes.ts @@ -25,15 +25,23 @@ export const get_domain_status = makeRoute({ let errorResponse = e as NextApiResponse; if (errorResponse.statusCode === 403) { try { - let verification = await vercel.projects.getProjectDomain({ - idOrName: "prj_9jX4tmYCISnm176frFxk07fF74kG", - teamId: "team_42xaJiZMTw9Sr7i0DcLTae9d", - domain, - }); - if (!verification.verification) return {}; + let [verification, config] = await Promise.all([ + vercel.projects.getProjectDomain({ + idOrName: "prj_9jX4tmYCISnm176frFxk07fF74kG", + teamId: "team_42xaJiZMTw9Sr7i0DcLTae9d", + domain, + }), + vercel.domains.getDomainConfig({ + domain, + teamId: "team_42xaJiZMTw9Sr7i0DcLTae9d", + }), + ]); + if (!verification.verification) { + return { config }; + } return { - error: "Verification_needed", verification: verification.verification, + config, } as const; } catch (e) { return { error: true }; diff --git a/app/lish/createPub/UpdatePubForm.tsx b/app/lish/createPub/UpdatePubForm.tsx index 9d5be628..21c69f4d 100644 --- a/app/lish/createPub/UpdatePubForm.tsx +++ b/app/lish/createPub/UpdatePubForm.tsx @@ -19,6 +19,7 @@ import { PinTiny } from "components/Icons/PinTiny"; import { Verification } from "@vercel/sdk/esm/models/getprojectdomainop"; import Link from "next/link"; import { Checkbox } from "components/Checkbox"; +import type { GetDomainConfigResponseBody } from "@vercel/sdk/esm/models/getdomainconfigop"; export const EditPubForm = () => { let { data } = usePublicationData(); @@ -188,7 +189,12 @@ export function CustomDomainForm() { let [state, setState] = useState< | { type: "default" } | { type: "addDomain" } - | { type: "domainSettings"; domain: string; verification?: Verification[] } + | { + type: "domainSettings"; + domain: string; + verification?: Verification[]; + config?: GetDomainConfigResponseBody; + } >({ type: "default" }); let domains = pubData?.publication_domains || []; @@ -208,6 +214,7 @@ export function CustomDomainForm() { ) : state.type === "domainSettings" ? ( setState({ type: "default" })} /> @@ -223,7 +230,8 @@ export function CustomDomainForm() { setState({ type: "domainSettings", domain: d.domain, - verification: v, + verification: v?.verification, + config: v?.config, }); }} /> @@ -312,14 +320,16 @@ function Domain(props: { domain: string; base_path: string; publication_uri: string; - setDomain: (v?: Verification[]) => void; + setDomain: (domain?: { + verification?: Verification[]; + config?: GetDomainConfigResponseBody; + }) => void; }) { let { data } = useSWR(props.domain, async (domain) => { return await callRPC("get_domain_status", { domain }); }); let pending = data?.config?.misconfigured || data?.error; - console.log(props.domain, data); return (
@@ -329,11 +339,7 @@ function Domain(props: { -
- - - ); - + if (!data) return; + let { config, verification } = data; + if (!config?.misconfigured && !verification) + return
This domain is verified!
; return (
To verify this domain, add the following record to your DNS provider for{" "} {props.domain}.
- - {isSubdomain ? ( -
-
-
Type
-
CNAME
-
-
-
Name
-
- {props.domain.split(".").slice(0, -2).join(".")} -
-
-
-
Value
-
cname.vercel-dns.com
-
-
- ) : ( -
-
-
Type
-
A
-
-
-
Name
-
@
-
-
-
Value
-
76.76.21.21
-
-
- )} - + + + + + + + + + + {verification && ( + + + + + + )} + {config && + (isSubdomain ? ( + + + + + + ) : ( + + + + + + ))} + {config?.configuredBy === "CNAME" && config.recommendedCNAME[0] && ( + + )} + +
TypeNameValue
+
{verification[0].type}
+
+
+ {verification[0].domain} +
+
+
+ {verification?.[0].value} +
+
+
CNAME
+
+
+ {props.domain.split(".").slice(0, -2).join(".")} +
+
+
+ { + config?.recommendedCNAME.sort( + (a, b) => a.rank - b.rank, + )[0].value + } +
+
+
A
+
+
@
+
+
+ { + config?.recommendedIPv4.sort((a, b) => a.rank - b.rank)[0] + .value + } +
+
+
+ + mutate()} /> +
); }; + +const VerifyButton = (props: { verify: () => Promise }) => { + let [loading, setLoading] = useState(false); + return ( + + ); +}; diff --git a/package-lock.json b/package-lock.json index e32795e4..1e9349d1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -36,7 +36,7 @@ "@types/mdx": "^2.0.13", "@vercel/analytics": "^1.5.0", "@vercel/functions": "^2.2.12", - "@vercel/sdk": "^1.3.1", + "@vercel/sdk": "^1.11.4", "babel-plugin-react-compiler": "^19.1.0-rc.1", "base64-js": "^1.5.1", "colorjs.io": "^0.5.2", @@ -6686,11 +6686,22 @@ } }, "node_modules/@vercel/sdk": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@vercel/sdk/-/sdk-1.3.1.tgz", - "integrity": "sha512-lTzG17DIDEJlWaGRNVyLZ17p8NRMOE2U98Kg96r1q79LGC8nPthoWhxupHXxGk3eAjjsvp8OA3bncKEyCHcofg==", + "version": "1.11.4", + "resolved": "https://registry.npmjs.org/@vercel/sdk/-/sdk-1.11.4.tgz", + "integrity": "sha512-TlLGQq6ToqnGhICQjvAyjSJkrHsLtqIM+nZuGV/SiamwSzXjiTpeTAe5wMDAao7LPJ9Efir/z76TvXFbLlW/9Q==", + "dependencies": { + "zod": "^3.20.0" + }, + "bin": { + "mcp": "bin/mcp-server.js" + }, "peerDependencies": { - "zod": ">= 3" + "@modelcontextprotocol/sdk": ">=1.5.0 <1.10.0" + }, + "peerDependenciesMeta": { + "@modelcontextprotocol/sdk": { + "optional": true + } } }, "node_modules/abort-controller": { diff --git a/package.json b/package.json index 699bf8d4..f231a83b 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@types/mdx": "^2.0.13", "@vercel/analytics": "^1.5.0", "@vercel/functions": "^2.2.12", - "@vercel/sdk": "^1.3.1", + "@vercel/sdk": "^1.11.4", "babel-plugin-react-compiler": "^19.1.0-rc.1", "base64-js": "^1.5.1", "colorjs.io": "^0.5.2",