How is-a.dev Handles TXT Record Strings: DNS Configuration Logic Explained

is-a.dev processes TXT record strings by accepting either single values or arrays, automatically wrapping values of 255 characters or fewer in double quotes, and injecting a mandatory _zone-updated timestamp marker into every DNS zone.

The is-a-dev/register repository automates DNS configuration for the is-a.dev subdomain service through JavaScript-based record generation. Understanding how is-a.dev handles TXT record strings is essential for users configuring email verification, domain ownership proof, or SPF records. The implementation at dnsconfig.js distinguishes between scalar and array inputs while enforcing DNS protocol limits through automated formatting and validation.

TXT Record Input Formats

Users can submit TXT records as either a single string or an array of strings within the records.TXT field of their JSON payload. The generator detects the format using Array.isArray() to determine whether to iterate over multiple values or process a single entry. This flexibility allows users to define multiple verification strings or policy records under one subdomain without creating separate configuration files.

Array Handling vs Single Values

When data.records.TXT is an array, the code loops through each element at lines 121-130 of dnsconfig.js. For scalar values, it processes the string directly through the same validation path. Both approaches feed into identical length-checking logic that determines finalrecord formatting.

Automatic Quoting Based on String Length

DNS TXT records require specific formatting to prevent parsing errors, but the is-a.dev generator applies quoting conditionally. Values with a length of 255 characters or fewer—the standard DNS TXT limit—are automatically wrapped in double quotes. Longer strings are passed through unmodified to accommodate raw record data that may contain pre-existing formatting or escape sequences.

// From dnsconfig.js lines 121-130
if (data.records.TXT) {
  if (Array.isArray(data.records.TXT)) {
    for (var txt in data.records.TXT) {
      records.push(
        TXT(subdomainName,
            data.records.TXT[txt].length <= 255
              ? `"${data.records.TXT[txt]}"`
              : data.records.TXT[txt])
      );
    }
  } else {
    records.push(
      TXT(subdomainName,
          data.records.TXT.length <= 255
            ? `"${data.records.TXT}"`
            : data.records.TXT)
    );
  }
}

The Zone Update Marker

Independent of user-submitted data, every DNS configuration automatically includes a special TXT record indicating when the zone was last generated. At lines 146-147 of dnsconfig.js, the system appends a TXT("_zone-updated", "<timestamp>") entry to track zone refreshes internally.

// From dnsconfig.js lines 146-147
records.push(TXT("_zone-updated", new Date().toISOString()));

This marker allows administrators to verify that recent changes have propagated through the DNS infrastructure without inspecting individual user records.

Validation in the Test Suite

The test suite at tests/records.test.js enforces type safety for TXT records across lines 236-242. Each value—whether extracted from an array or checked as a scalar—must be a JavaScript string, preventing type errors during DNS propagation that could cause zone compilation failures.

// From tests/records.test.js lines 236-242
if (key === "TXT") {
  const values = Array.isArray(value) ? value : [value];
  values.forEach((record, idx) => {
    t.true(typeof record === "string",
      `${file}: TXT record value should be a string at index ${idx}`);
  });
}

Summary

  • Flexible Input: Accepts single strings or arrays in the records.TXT field of user JSON payloads.
  • Smart Quoting: Automatically wraps values of 255 characters or fewer in double quotes; leaves longer strings untouched.
  • Internal Tracking: Always appends a _zone-updated TXT record containing the generation timestamp.
  • Type Safety: The test suite validates that every TXT entry is a string type before deployment.

Frequently Asked Questions

Can I submit multiple TXT records for one subdomain?

Yes. Submit an array of strings in the records.TXT field of your JSON file. The generator at dnsconfig.js iterates through each entry using a for...in loop and creates individual DNS records for every array element.

Why are some TXT values wrapped in quotes and others not?

Values containing 255 or fewer characters receive automatic double quotes to comply with standard DNS TXT record formatting requirements. Values exceeding this length remain unmodified to prevent interference with pre-formatted record data or escape sequences that the user intentionally included.

What is the _zone-updated TXT record?

This is an internal marker that the system appends to every DNS zone at lines 146-147 of dnsconfig.js. It contains an ISO timestamp indicating when the zone configuration was generated, helping administrators track refresh cycles and verify propagation status independently of user-submitted records.

How does is-a.dev validate TXT record submissions?

The test suite in tests/records.test.js (lines 236-242) iterates through all TXT entries to verify that every value is a JavaScript string. It normalizes both single values and arrays into a consistent format before checking types, ensuring that the DNS compiler receives valid input regardless of how users structure their JSON.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →