mirror of
https://github.com/hanzo-apps/dataroom.git
synced 2026-10-30 14:47:36 +00:00
What was left was all internal naming, none of it rendered — the strings a
user actually sees had already been changed. Cleared so a grep for the
upstream brand returns only the attribution that is supposed to be there.
- components/shared/icons/papermark-sparkle.tsx deleted. It was imported
into components/view/nav.tsx and never rendered, so this is dead code,
not a rename.
- components/emails/year-in-review-papermark.tsx -> year-in-review.tsx,
and PapermarkYearInReviewEmailProps -> YearInReviewEmailProps. The email
body was already Hanzo Dataroom throughout; only the file and the
interface still said otherwise.
- PAPERMARK_HEADERS -> APP_HEADERS. Its value already read from
NEXT_PUBLIC_APP_NAME.
- papermarkUserId -> authenticatedUserId on TusAuthenticatedRequest.
- isPapermarkUrl -> isDataroomUrl, and its condition no longer tests
dataroom.hanzo.ai/view/ twice — a rewrite had collapsed two upstream
domains into one and left the || behind.
- the shadow database in prisma/add-migration.sh, and two comments.
LICENSE and LLM.md keep every mention: AGPL-3.0 with upstream's copyright
line, and the note recording what this is forked from. Per HIP-0137 those do
not get edited, and the point of this commit is that the brand should appear
where the licence requires it and nowhere else.
Co-authored-by: Hanzo Dev <[email protected]>
135 lines
3.9 KiB
TypeScript
135 lines
3.9 KiB
TypeScript
import {
|
|
DomainConfigResponse,
|
|
DomainResponse,
|
|
DomainVerificationResponse,
|
|
} from "@/lib/types";
|
|
|
|
export const addDomainToVercel = async (domain: string) => {
|
|
return await fetch(
|
|
`https://api.vercel.com/v10/projects/${process.env.PROJECT_ID_VERCEL}/domains?teamId=${process.env.TEAM_ID_VERCEL}`,
|
|
{
|
|
method: "POST",
|
|
headers: {
|
|
Authorization: `Bearer ${process.env.AUTH_BEARER_TOKEN}`,
|
|
"Content-Type": "application/json",
|
|
},
|
|
body: JSON.stringify({
|
|
name: domain.toLowerCase(),
|
|
}),
|
|
},
|
|
).then((res) => res.json());
|
|
};
|
|
|
|
export const removeDomainFromVercelProject = async (domain: string) => {
|
|
return await fetch(
|
|
`https://api.vercel.com/v9/projects/${process.env.PROJECT_ID_VERCEL}/domains/${domain}?teamId=${process.env.TEAM_ID_VERCEL}`,
|
|
{
|
|
headers: {
|
|
Authorization: `Bearer ${process.env.AUTH_BEARER_TOKEN}`,
|
|
},
|
|
method: "DELETE",
|
|
},
|
|
).then((res) => res.json());
|
|
};
|
|
|
|
export const removeDomainFromVercelTeam = async (domain: string) => {
|
|
return await fetch(
|
|
`https://api.vercel.com/v6/domains/${domain}?teamId=${process.env.TEAM_ID_VERCEL}`,
|
|
{
|
|
headers: {
|
|
Authorization: `Bearer ${process.env.AUTH_BEARER_TOKEN}`,
|
|
},
|
|
method: "DELETE",
|
|
},
|
|
).then((res) => res.json());
|
|
};
|
|
|
|
export const removeDomainFromVercel = async (
|
|
domain: string,
|
|
domainCount: number,
|
|
) => {
|
|
if (domainCount > 1) {
|
|
// the apex domain is being used by other domains
|
|
// so we should only remove it from our Vercel project
|
|
removeDomainFromVercelProject(domain);
|
|
} else {
|
|
// this is the only domain using this apex domain
|
|
// so we can remove it entirely from our Vercel team
|
|
removeDomainFromVercelProject(domain);
|
|
removeDomainFromVercelTeam(domain);
|
|
}
|
|
};
|
|
|
|
export const getDomainResponse = async (
|
|
domain: string,
|
|
): Promise<DomainResponse & { error: { code: string; message: string } }> => {
|
|
return await fetch(
|
|
`https://api.vercel.com/v9/projects/${process.env.PROJECT_ID_VERCEL}/domains/${domain.toLowerCase()}?teamId=${process.env.TEAM_ID_VERCEL}`,
|
|
{
|
|
method: "GET",
|
|
headers: {
|
|
Authorization: `Bearer ${process.env.AUTH_BEARER_TOKEN}`,
|
|
"Content-Type": "application/json",
|
|
},
|
|
},
|
|
).then((res) => {
|
|
return res.json();
|
|
});
|
|
};
|
|
|
|
export const getConfigResponse = async (
|
|
domain: string,
|
|
): Promise<DomainConfigResponse> => {
|
|
return await fetch(
|
|
`https://api.vercel.com/v6/domains/${domain.toLowerCase()}/config?teamId=${process.env.TEAM_ID_VERCEL}`,
|
|
{
|
|
method: "GET",
|
|
headers: {
|
|
Authorization: `Bearer ${process.env.AUTH_BEARER_TOKEN}`,
|
|
"Content-Type": "application/json",
|
|
},
|
|
},
|
|
).then((res) => res.json());
|
|
};
|
|
|
|
export const verifyDomain = async (
|
|
domain: string,
|
|
): Promise<DomainVerificationResponse> => {
|
|
return await fetch(
|
|
`https://api.vercel.com/v9/projects/${process.env.PROJECT_ID_VERCEL}/domains/${domain.toLowerCase()}/verify?teamId=${process.env.TEAM_ID_VERCEL}`,
|
|
{
|
|
method: "POST",
|
|
headers: {
|
|
Authorization: `Bearer ${process.env.AUTH_BEARER_TOKEN}`,
|
|
"Content-Type": "application/json",
|
|
},
|
|
},
|
|
).then((res) => res.json());
|
|
};
|
|
|
|
export const getSubdomain = (name: string, apexName: string) => {
|
|
if (name === apexName) return null;
|
|
return name.slice(0, name.length - apexName.length - 1);
|
|
};
|
|
|
|
export const getApexDomain = (url: string) => {
|
|
let domain;
|
|
try {
|
|
domain = new URL(url).hostname;
|
|
} catch (e) {
|
|
return "";
|
|
}
|
|
const parts = domain.split(".");
|
|
if (parts.length > 2) {
|
|
// if it's a subdomain (e.g. app.vercel.app), return the last 2 parts
|
|
return parts.slice(-2).join(".");
|
|
}
|
|
// if it's a normal domain (e.g. dataroom.hanzo.ai), we return the domain
|
|
return domain;
|
|
};
|
|
|
|
// courtesy of ChatGPT: https://sharegpt.com/c/pUYXtRs
|
|
export const validDomainRegex = new RegExp(
|
|
/^([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,
|
|
);
|