Skip to content

Commit da7646b

Browse files
committed
vercel verify services key support
1 parent 8efc2ca commit da7646b

File tree

5 files changed

+63
-8
lines changed

5 files changed

+63
-8
lines changed

dnsconfig.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,16 @@ for (var subdomain in domains) {
145145
records.push(TXT("_discord." + subdomainName, "\"" + data.services.discord + "\""));
146146
}
147147
}
148+
149+
if (data.services.vercel) {
150+
if (Array.isArray(data.services.vercel)) {
151+
for (var txt in data.services.vercel) {
152+
records.push(TXT("_vercel." + subdomainName, "\"" + data.services.vercel[txt] + "\""));
153+
}
154+
} else {
155+
records.push(TXT("_vercel." + subdomainName, "\"" + data.services.vercel + "\""));
156+
}
157+
}
148158
}
149159
}
150160

tests/domains.test.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,7 @@ t("Nested subdomains should not exist without a parent subdomain", (t) => {
3030
const parent = parts.slice(i).join(".");
3131
if (parent.startsWith("_")) continue;
3232

33-
t.true(
34-
files.includes(`${parent}.json`),
35-
`${file}: Parent subdomain "${parent}" does not exist`
36-
);
33+
t.true(files.includes(`${parent}.json`), `${file}: Parent subdomain "${parent}" does not exist`);
3734
}
3835
});
3936
});
@@ -111,8 +108,18 @@ t("Disallow nested subdomains when parent has specific service records", (t) =>
111108
const subdomain = file.replace(/\.json$/, "");
112109
const data = getDomainData(subdomain);
113110

114-
if(data?.services?.discord) {
115-
t.false(files.includes(`_discord.${file}`), `${file}: Nested subdomain "_discord.${subdomain}" should not exist when services.discord is present`);
111+
if (data?.services?.discord) {
112+
t.false(
113+
files.includes(`_discord.${file}`),
114+
`${file}: Nested subdomain "_discord.${subdomain}" should not exist when services.discord is present`
115+
);
116+
}
117+
118+
if (data?.services?.vercel) {
119+
t.false(
120+
files.includes(`_vercel.${file}`),
121+
`${file}: Nested subdomain "_vercel.${subdomain}" should not exist when services.vercel is present`
122+
);
116123
}
117124
});
118125

tests/json.test.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,14 @@ async function processFile(file, t) {
154154
if (data.services.discord) {
155155
t.true(
156156
Array.isArray(data.services.discord) || typeof data.services.discord === "string",
157-
`${file}: Discord service should be an array or string`
157+
`${file}: services.discord should be an array or string`
158+
);
159+
}
160+
161+
if (data.services.vercel) {
162+
t.true(
163+
Array.isArray(data.services.vercel) || typeof data.services.vercel === "string",
164+
`${file}: services.vercel should be an array or string`
158165
);
159166
}
160167
}

tests/records.test.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,14 +339,23 @@ t("All files should have valid service records", (t) => {
339339
discord.forEach((value) => {
340340
const token = value.split("=")[1];
341341

342-
t.true(value.startsWith("dh="), `${file}: Discord service record should start with "dh="`);
342+
t.true(value.startsWith("dh="), `${file}: Invalid Discord service record format`);
343343
t.true(token.length === 40, `${file}: Discord service token should be 40 characters long`);
344344
t.true(
345345
isValidHexadecimal(token),
346346
`${file}: Discord service token should be a valid hexadecimal string`
347347
);
348348
});
349349
}
350+
351+
if (data?.services?.vercel) {
352+
const vercel = Array.isArray(data.services.vercel) ? data.services.vercel : [data.services.vercel];
353+
354+
vercel.forEach((value) => {
355+
t.true(value.startsWith("vc-domain-verify="), `${file}: Invalid Vercel service record format`);
356+
t.true(value.length > 48, `${file}: Vercel service token should be longer than 48 characters`);
357+
});
358+
}
350359
});
351360

352361
t.pass();

util/raw-api.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,28 @@ fs.readdir(directoryPath, function (err, files) {
134134
}
135135
});
136136
}
137+
138+
if (item.services.vercel) {
139+
const vercel = Array.isArray(item.services.vercel) ? item.services.vercel : [item.services.vercel];
140+
141+
v1.push({
142+
domain: `_vercel.${item.domain}`,
143+
subdomain: `_vercel.${item.subdomain}`,
144+
owner: item.owner,
145+
record: {
146+
TXT: vercel
147+
}
148+
});
149+
150+
v2.push({
151+
domain: `_vercel.${item.domain}`,
152+
subdomain: `_vercel.${item.subdomain}`,
153+
owner: item.owner,
154+
records: {
155+
TXT: vercel
156+
}
157+
});
158+
}
137159
}
138160

139161
processedCount++;

0 commit comments

Comments
 (0)