···11+// List of domains that are not supported for slices
22+const UNSUPPORTED_DOMAINS = [
33+ "app.bsky",
44+ "com.atproto",
55+];
66+77+export function validateDomain(domain: string): string | null {
88+ const trimmedDomain = domain.trim();
99+1010+ if (!trimmedDomain || trimmedDomain.length === 0) {
1111+ return "Domain is required";
1212+ }
1313+1414+ if (UNSUPPORTED_DOMAINS.includes(trimmedDomain)) {
1515+ return `The domain '${trimmedDomain}' is not supported`;
1616+ }
1717+1818+ // Domain must have at least two parts (e.g. social.grain)
1919+ if (!trimmedDomain.includes('.')) {
2020+ return "Domain must have at least two parts (e.g. social.grain)";
2121+ }
2222+2323+ // Validate domain format
2424+ const domainRegex = /^[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?)+$/;
2525+ if (!domainRegex.test(trimmedDomain)) {
2626+ return "Domain must be a valid format (e.g. social.grain)";
2727+ }
2828+2929+ return null; // Valid
3030+}
3131+3232+// Function to get the list of unsupported domains (for debugging/admin purposes)
3333+export function getUnsupportedDomains(): readonly string[] {
3434+ return UNSUPPORTED_DOMAINS;
3535+}