Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

moved blacklisted domains + emails to edge config

Steven Tey66294667d502
diff --git a/lib/constants/blacklist.ts b/lib/constants/blacklist.ts
deleted file mode 100644
index 67a77373be..0000000000
--- a/lib/constants/blacklist.ts
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- ************************************************
- * Crowdsourced list of blacklisted domains
- ************************************************
- * How to contribute:
- * 1. Find a domain that you think should be blacklisted (contain phishing links, spam links, pornographic content, etc.)
- * 2. Do a "CMD/CTRL + F" search for the domain in this file
- * 3. If the domain is not found, make a pull request with the domain added to the blacklist
- */
-
-const BLACKLIST = new Set([
- "lopescarvalho.adv.br",
- "gruppopiueuroparegionelazio.it",
- "piracynchill.in",
- "tgnewstv.it",
- "secure.oldschool.com-os.cz",
- "secure.oldschool.com-o.cz",
- "secure.oldschool.com-rr.cz",
- "secure.oldschool.com-i.cz",
- "rfiptv.xyz",
- "uiptv.ml",
- "8wogq.app.link",
- "w3hir.app.link",
- "jessie.5jnwb9k6op.monster",
- "christy.yhujykujujk.xyz",
- "jleog.app.link",
- "gc891.app.link",
- "alena.ytuiljhnvbh.xyz",
- "sehyf.app.link",
- "3cn8j.app.link",
- "heather.tryhfchgc.xyz",
- "allie.1e35tmecro.monster",
- "karen.nbmfdhcb.xyz",
- "ryan.tryhfchgc.xyz",
- "hndou.app.link",
- "61fcu.app.link",
- "nkz64.app.link",
- "chelsie.adfvsergtbaf.xyz",
- "8vuqh.app.link",
- "jodie.vbnmfhfdc.xyz",
- "jh534.app.link",
- "922555d.dwerls.eu.org",
- "6521d.app.link",
- "fad0fb.gartenleben.eu.org",
- "bcxui.app.link",
- "kiera.vbnmfhfdc.xyz",
- "uvne4.app.link",
- "4lwkf.app.link",
- "ccw50.app.link",
- "1d6b8ac2d1.huyts.eu.org",
- "hannah.muyjykjhrfd.xyz",
- "f5hgd.app.link",
- "cf7ee9bd.dwerls.eu.org",
- "c3494cbf0.sewdo.eu.org",
- "9056af2adf.sewdo.eu.org",
- "donna.yrcbdfhhfd.xyz",
- "88nab.app.link",
- "80ac6ecc2.huyts.eu.org",
- "305b8fa.kipoks.eu.org",
- "6be3fa26.huyts.eu.org",
- "befc44e645.huyts.eu.org",
- "lindsey.yhujykujujk.xyz",
- "kristie.ryutghfdhhdf.xyz",
- "esmeralda.vcnfhcb.xyz",
- "1bgq4.app.link",
- "12b7a7.kipoks.eu.org",
- "kassie.rtymjkuyxdg.xyz",
- "tierra.1e35tmecro.monster",
- "ux56b.app.link",
- "0tkmd.app.link",
- "bmzau.app.link",
- "b0daea.sewdo.eu.org",
- "nia.rdhychbxc.xyz",
- "kristina.fthfcn.xyz",
- "jdeih.app.link",
- "cgjj7.app.link",
- "daniela.yrcbdfhhfd.xyz",
- "anjelica.nbmfdhcb.xyz",
- "38b31c40.sunid.eu.org",
- "e98d65a3.huyts.eu.org",
- "fe9139f.huyts.eu.org",
- "dfd43a244a.gartenleben.eu.org",
- "6683ee5849.kipoks.eu.org",
- "813dce2726.sunid.eu.org",
- "5240c2608e.sunid.eu.org",
- "kiersten.rtymjkuyxdg.xyz",
- "katheryn.yrcbdfhhfd.xyz",
- "lizbeth.yrcbdfhhfd.xyz",
- "norma.ryutghfdhhdf.xyz",
- "clarissa.yuikjufgdsdh.xyz",
- "sidney.bvnfdhcbcb.xyz",
- "4e04cc6a9.huyts.eu.org",
- "06e257b3e.sewdo.eu.org",
- "ff4ed7a326.dwerls.eu.org",
- "kyra.bnfdhcvb.xyz",
- "angie.7trp0c5oep.monster",
- "chelsea.afedafdadc.xyz",
- "rachel.7trp0c5oep.monster",
- "meaghan.fzuzj04e6n.monster",
- "patricia.rtymjkuyxdg.xyz",
- "alexandra.bvnfdhcbcb.xyz",
- "micaela.vjnvvcmcxbxxd.xyz",
- "stacie.ytuiljhnvbh.xyz",
- "priscilla.5jnwb9k6op.monster",
- "cindy.ryutghfdhhdf.xyz",
- "aja.rdyfcdgcb.xyz",
- "dianna.muyjykjhrfd.xyz",
- "scarlett.rdhychbxc.xyz",
- "amelia.rdhychbxc.xyz",
- "fiona.ryutghfdhhdf.xyz",
- "sasha.adcfazdfc.xyz",
- "charity.yrcbdfhhfd.xyz",
- "ffthy.app.link",
- "a588eb0.huyts.eu.org",
- "6dbbfab8c.huyts.eu.org",
- "alison.bvnfdhcbcb.xyz",
- "chelsey.tyyithkgj.xyz",
- "tammy.bnfdhcvb.xyz",
- "genevieve.klkyfedrwere.xyz",
- "leeann.trugvfhjfg.xyz",
- "alexandrea.bvnfdhcbcb.xyz",
- "caitlin.retryfhdfg.xyz",
- "gillian.yhujykujujk.xyz",
- "marlena.adcfazdfc.xyz",
- "april.o37mr0twx4.monster",
- "adrian.bmndsgfxc.xyz",
- "claudia.tr9vznl3ca.monster",
- "naomi.yikjcvbdfg.xyz",
- "amanda.ryutghfdhhdf.xyz",
- "celia.o37mr0twx4.monster",
- "morgan.htgyrfhrf.xyz",
- "carlee.vbnmfhfdc.xyz",
- "misty.ytuiljhnvbh.xyz",
- "katlynn.adfvsergtbaf.xyz",
- "sadie.trugvfhjfg.xyz",
- "francheska.hgtghyktdfh.xyz",
- "celine.trugvfhjfg.xyz",
- "mara.adfvsergtbaf.xyz",
- "alexia.tryhfchgc.xyz",
- "elaina.5xunbtlxqb.monster",
- "iliana.ytuiljhnvbh.xyz",
- "0ky2g.app.link",
- "e986b6.dwerls.eu.org",
- "bb333aed.sewdo.eu.org",
- "cristina.adcfazdfc.xyz",
- "olga.htgyrfhrf.xyz",
- "hailey.fzuzj04e6n.monster",
- "gabriela.klkyfedrwere.xyz",
- "isabel.bnfdhcvb.xyz",
- "helena.0x8n2g2slw.monster",
- "kalie.trugvfhjfg.xyz",
- "kendra.htgyrfhrf.xyz",
- "annamarie.bmndsgfxc.xyz",
- "felicia.yikjcvbdfg.xyz",
- "imani.bnfdhcvb.xyz",
- "ayanna.7trp0c5oep.monster",
- "fatima.o37mr0twx4.monster",
- "iliana.bmndsgfxc.xyz",
- "aisha.ryutghfdhhdf.xyz",
- "896b5e.gartenleben.eu.org",
- "b651fe980.dwerls.eu.org",
- "danielle.yrcbdfhhfd.xyz",
- "eliza.5jnwb9k6op.monster",
- "madeleine.bvnfdhcbcb.xyz",
- "8024510.bait.sa.com",
- "15fbd7.kipoks.eu.org",
- "15942eca.sewdo.eu.org",
- "24bc42a.sunid.eu.org",
- "f29368aa90.sunid.eu.org",
- "682rb.app.link",
- "74.mchs.gov.ru",
- "mchs.gov.ru",
- "zdqq.xyz",
- "reg.eda.yandex.ru",
- // porn sites
- "pornhub.com",
- "redtube.com",
- "xnxx.com",
- "xvideos.com",
- "xhamster.com",
- "spankbang.com",
- "youporn.com",
- "tube8.com",
- // free URL shortening services
- "rb.gy",
- "in.sv",
- "tdy.es",
- "shortest.link",
- "zws.im",
-]);
-
-export default BLACKLIST;
diff --git a/lib/constants/blacklisted-emails.ts b/lib/constants/blacklisted-emails.ts
deleted file mode 100644
index 91d44d3c57..0000000000
--- a/lib/constants/blacklisted-emails.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-const BLACKLISTED_EMAILS = new Set([
-]);
-
-export default BLACKLISTED_EMAILS;
diff --git a/lib/constants/index.ts b/lib/constants/index.ts
index cf98a5bba1..d6e3e3c210 100644
--- a/lib/constants/index.ts
+++ b/lib/constants/index.ts
@@ -41,6 +41,3 @@ export const SECOND_LEVEL_DOMAINS = new Set([
export const SPECIAL_APEX_DOMAINS = {
"youtu.be": "youtube.com",
};
-
-export { default as BLACKLIST } from "./blacklist";
-export { default as BLACKLISTED_EMAILS } from "./blacklisted-emails";
diff --git a/lib/utils.ts b/lib/utils.ts
index 396c9add8d..785d43c85c 100644
--- a/lib/utils.ts
+++ b/lib/utils.ts
@@ -318,3 +318,27 @@ export const log = async (message: string, type: "cron" | "links") => {
console.log(`Failed to log to Vercel Slack. Error: ${e}`);
}
};
+
+export const getBlackListedDomains = async () => {
+ const res = await fetch(
+ `https://edge-config.vercel.com/ecfg_2yhwl7yp0dcf60nn1cdid4a5xlsa?token=2482c0cb-1101-4e4b-8538-0f54cc43469e`,
+ );
+ const data = await res.json();
+ if (data.domains) {
+ return new Set(data.domains);
+ } else {
+ return new Set();
+ }
+};
+
+export const getBlackListedEmails = async () => {
+ const res = await fetch(
+ `https://edge-config.vercel.com/ecfg_yugfr9n59gbwswp2lcdfbxrxfjir?token=${process.env.EDGE_CONFIG_TOKEN}`,
+ );
+ const data = await res.json();
+ if (data.emails) {
+ return new Set(data.emails);
+ } else {
+ return new Set();
+ }
+};
diff --git a/pages/api/auth/[...nextauth].tsx b/pages/api/auth/[...nextauth].tsx
index 202050ec5d..31e4315805 100644
--- a/pages/api/auth/[...nextauth].tsx
+++ b/pages/api/auth/[...nextauth].tsx
@@ -5,7 +5,7 @@ import WelcomeEmail from "emails/WelcomeEmail";
import NextAuth, { type NextAuthOptions } from "next-auth";
import EmailProvider from "next-auth/providers/email";
import prisma from "@/lib/prisma";
-import { BLACKLISTED_EMAILS } from "@/lib/constants";
+import { getBlackListedEmails } from "@/lib/utils";
const VERCEL_DEPLOYMENT = !!process.env.VERCEL_URL;
@@ -38,12 +38,14 @@ export const authOptions: NextAuthOptions = {
},
callbacks: {
signIn: async ({ user }) => {
+ const BLACKLISTED_EMAILS = await getBlackListedEmails();
if (BLACKLISTED_EMAILS.has(user.email)) {
return false;
}
return true;
},
jwt: async ({ token, account, profile }) => {
+ const BLACKLISTED_EMAILS = await getBlackListedEmails();
if (BLACKLISTED_EMAILS.has(token.email)) {
return {};
}
diff --git a/pages/api/edge/links/index.ts b/pages/api/edge/links/index.ts
index 8a4300be0a..5154844255 100644
--- a/pages/api/edge/links/index.ts
+++ b/pages/api/edge/links/index.ts
@@ -1,7 +1,6 @@
import type { NextRequest } from "next/server";
import { setRandomKey } from "@/lib/upstash";
-import { BLACKLIST } from "@/lib/constants";
-import { getDomainWithoutWWW } from "@/lib/utils";
+import { getBlackListedDomains, getDomainWithoutWWW } from "@/lib/utils";
export const config = {
runtime: "experimental-edge",
@@ -13,7 +12,8 @@ export default async function handler(req: NextRequest) {
if (!url) {
return new Response(`Missing url`, { status: 400 });
}
- if (BLACKLIST.has(getDomainWithoutWWW(url))) {
+ const BLACKLISTED_DOMAINS = await getBlackListedDomains();
+ if (BLACKLISTED_DOMAINS.has(getDomainWithoutWWW(url))) {
return new Response(`Invalid url`, { status: 400 });
}
const { response, key } = await setRandomKey(url);
diff --git a/pages/api/links/[key]/index.ts b/pages/api/links/[key]/index.ts
index 2c83c9ed08..0e69cde69c 100644
--- a/pages/api/links/[key]/index.ts
+++ b/pages/api/links/[key]/index.ts
@@ -2,8 +2,7 @@ import { NextApiRequest, NextApiResponse } from "next";
import { deleteLink, editLink } from "@/lib/api/links";
import { Session, withUserAuth } from "@/lib/auth";
import prisma from "@/lib/prisma";
-import { BLACKLIST } from "@/lib/constants";
-import { getDomainWithoutWWW } from "@/lib/utils";
+import { getBlackListedDomains, getDomainWithoutWWW } from "@/lib/utils";
const domain = "dub.sh";
@@ -33,7 +32,8 @@ export default withUserAuth(
.status(400)
.json({ error: "Missing key or url or title or timestamp" });
}
- if (BLACKLIST.has(getDomainWithoutWWW(url))) {
+ const BLACKLISTED_DOMAINS = await getBlackListedDomains();
+ if (BLACKLISTED_DOMAINS.has(getDomainWithoutWWW(url))) {
return res.status(400).json({ error: "Invalid url" });
}
const response = await editLink(
diff --git a/pages/api/links/index.ts b/pages/api/links/index.ts
index 0b1b5e94fd..d0b40261a6 100644
--- a/pages/api/links/index.ts
+++ b/pages/api/links/index.ts
@@ -1,8 +1,7 @@
import { NextApiRequest, NextApiResponse } from "next";
import { addLink, getLinksForProject } from "@/lib/api/links";
import { Session, withUserAuth } from "@/lib/auth";
-import { BLACKLIST } from "@/lib/constants";
-import { getDomainWithoutWWW } from "@/lib/utils";
+import { getBlackListedDomains, getDomainWithoutWWW } from "@/lib/utils";
import { log } from "@/lib/utils";
// This is a special route for retrieving and creating custom dub.sh links.
@@ -29,7 +28,8 @@ export default withUserAuth(
if (!key || !url) {
return res.status(400).json({ error: "Missing key or url" });
}
- if (BLACKLIST.has(getDomainWithoutWWW(url))) {
+ const BLACKLISTED_DOMAINS = await getBlackListedDomains();
+ if (BLACKLISTED_DOMAINS.has(getDomainWithoutWWW(url))) {
return res.status(400).json({ error: "Invalid url" });
}
const response = await addLink({