import type { WorkOSOrganizationDomain } from './entities.js'; import type { WorkOSStore } from './store.js'; /** * The states `domain_data` may declare. Production's DTO refuses `legacy_verified` and `failed` * on input: those are states a domain reaches, never ones a caller sets. */ export declare const INITIAL_DOMAIN_STATES: readonly ['pending', 'verified']; export type InitialDomainState = (typeof INITIAL_DOMAIN_STATES)[number]; export interface DomainDataEntry { domain: string; state: InitialDomainState; } /** Production's `normalizeDomain`: a domain is stored and compared trimmed and lowercased. */ export declare function normalizeDomain(domain: string): string; /** * Production validates a domain with `is-valid-domain@0.1.6` under `{ subdomain: true }`; this is * that check ported rather than depended on (the package loads Node's deprecated `punycode`). * A domain is at most 253 characters of letters, digits, hyphens, underscores and dots, with at * least two labels; each label is under 64 characters and neither starts nor ends with a hyphen; * the TLD is not all digits; the registrable label (the one before the TLD) allows no underscore * and no `--` other than an IDN `xn--` prefix. Internationalized names must arrive in that * punycode form: production never passes `allowUnicode`, so `bücher.de` is refused and * `xn--bcher-kva.de` accepted. * * One divergence: the package also knows public second-level suffixes (`co.uk`), so it holds * `foo` in `foo.co.uk` to the registrable-label rules, whereas this port holds `co` to them. An * underscore or stray `--` in such a label passes here and fails in production. */ export declare function isValidDomain(value: unknown): boolean; /** Production's `isCommonConsumerDomain`: membership in its public consumer-mail list. */ export declare function isCommonConsumerDomain(domain: string): boolean; /** * Production's `ensureNoConsumerDomains`: the first consumer domain among those about to be * attached is refused with the organization routes' 422. */ export declare function rejectConsumerDomains(domains: string[]): void; /** The token production mints when DNS verification starts: `generateToken('base62', 25)`. */ export declare function generateDomainVerificationToken(): string; /** * The `{ field, code }` errors production's validation pipe reports for a `domain_data` list, or * none. `code` is the failed class-validator constraint's message, as production renders it: * `domain` must satisfy `isValidDomain`, and `state` is required (`IsNotEmpty` reports first * when it is missing, empty or null) and must be one of INITIAL_DOMAIN_STATES. */ export declare function domainDataValidationErrors(entries: unknown[]): Array<{ field: string; code: string; }>; /** * Reads `domain_data` off an organization create or update body the way production does: absent * (or not a list) leaves the domains untouched; otherwise every entry is validated — 422 * `Validation failed` — and the list may not name a domain twice in any casing — 422 * `` `domain_data` must contain unique domains `` — before anything is written. Entries come * back normalized. */ export declare function parseDomainData(body: Record): DomainDataEntry[] | undefined; /** * Inserts a domain the way production's `createMany` does for `domain_data` (and the seed loader * for seeds): a verified domain records the `manual` strategy; a pending one carries no strategy, * token or prefix until verification starts (`startDnsVerification`). Fires * `organization_domain.created`. */ export declare function insertOrganizationDomain(ws: WorkOSStore, organizationId: string, { domain, state }: DomainDataEntry): WorkOSOrganizationDomain; /** * Production's `DomainVerifier.initiateVerification`: the domain goes (or stays) pending under the * `dns` strategy with a fresh token, and `organization_domain.updated` fires. The verification * prefix is left as it was — the API passes none, so API-created domains never gain one. Nothing * resolves DNS afterwards: the emulator runs no verification cron, so the domain stays pending. */ export declare function startDnsVerification(ws: WorkOSStore, domain: WorkOSOrganizationDomain): WorkOSOrganizationDomain;