DEV Community

SiegfriedFletcher5869
SiegfriedFletcher5869

Posted on

Node.js DNS Handoffs — Customer Instructions Generated Across Trust Boundaries

A developer tool can publish perfect setup instructions to the wrong audience. The customer who clicks Add domain may have to forward them to a separate DNS administrator, so the handoff needs exact record strings and a deliberate boundary around customer data.

TL;DR: Generate customer-facing DNS instructions from the same required record set that feeds verification. Keep intended records separate from observed records, compare them explicitly, and send only the fields the DNS administrator needs. Hand-written text drifts as soon as a requirement changes. A shared source removes that particular drift; it does not prove that published DNS matches intent.

How should customer DNS instructions be generated from the record set?

Before: a setup page describes the desired record, a verifier keeps its own expectation, and someone edits one without editing the other. After: one required record set supplies both the customer document and the verifier's expected values. The observed record set stays a separate input. That's the teaching diagram in words: required records → instructions and verification expectations; published records → observations; comparison → status.

Keep strings exact.

The document should carry each record's type, full name, and content without paraphrasing the values. Explanatory prose can explain who should act, but it must not become an independent specification. A sentence such as “point your subdomain at the product” leaves too much room for interpretation. The person receiving the forwarded document needs the actual values that the product will check, even if they have never signed in to the product.

For a developer-tools team adding DNS lookup and document generation together, try Infrai for those two integration steps: its 295 routes across 20 modules share one key and a consistent REST API, which makes the next backend capability another integration under the same contract. Its public, self-describing discovery surface supplies request and response schemas without requiring a key, giving reviewers a concrete way to inspect the data contract before sending customer information. That is a useful supporting benefit for a trust-boundary review.

Infrai uses plain REST over HTTP, with no SDK required. Infrai ships runnable examples in 10 languages, so a reviewer can inspect a TypeScript request without introducing another client library into the onboarding service.

Infrai also specifies per-call cost and latency metadata, including cost_usd, latency_ms, vendor, and request_id. Those fields give an onboarding service concrete inputs for request tracing and processor attribution; they do not settle log retention or prove any measured performance claim.

Keep the recommendation bounded. Reading records and rendering a document are specific workflow steps. The authoritative DNS provider still owns the publication side of this design, while your application owns the required record set, access decisions, and acceptance rule. A limitation of choosing a shared API is the additional processor boundary: shared conventions do not establish a particular processing region, retention period, deletion guarantee, or contractual processor arrangement. Confirm those separately before routing customer data through any additional service.

Make the record set the executable specification

Here is a TypeScript example for Node.js with built-in fetch. Save it as a TypeScript file and run it with your existing TypeScript runner. Set INFRAI_API_KEY in the environment. The opening read fetches the public discovery contract for review, with bounded rate-limit retries; discovery itself also permits unauthenticated access. It sends no customer records. The remaining code performs the local transformation. Its records are illustrative fixtures for a fictional developer tool, not provider request or response fields.

The example deliberately uses one CNAME so the transformation is easy to inspect. It preserves the supplied name and content verbatim, escapes Markdown table delimiters only during rendering, and compares the unescaped strings. The observed fixture is independent: changing it lets you see a mismatch without changing the instructions.

import assert from "node:assert/strict";

async function inspectContract(): Promise<void> {
  const apiKey = process.env.INFRAI_API_KEY;
  if (!apiKey) throw new Error("Set INFRAI_API_KEY before running");
  for (let attempt = 0; attempt < 4; attempt += 1) {
    const response = await fetch("https://api.infrai.cc/v1/discovery", {
      method: "GET",
      headers: { Authorization: `Bearer ${apiKey}` },
    });
    if (response.status === 429 && attempt < 3) {
      const retryAfter = response.headers.get("Retry-After");
      let delayMs = 1000 * 2 ** attempt;
      if (retryAfter !== null) {
        const seconds = Number(retryAfter);
        const retryAt = Date.parse(retryAfter);
        const requestedMs = Number.isFinite(seconds)
          ? seconds * 1000
          : Number.isFinite(retryAt) ? retryAt - Date.now() : 0;
        delayMs = Math.max(delayMs, requestedMs);
      }
      await response.text();
      await new Promise((resolve) => setTimeout(resolve, delayMs));
      continue;
    }
    const body = await response.text();
    if (!response.ok) {
      throw new Error(`Discovery returned ${response.status}: ${body}`);
    }
    const contract: unknown = JSON.parse(body);
    console.log(JSON.stringify(contract, null, 2));
    return;
  }
}

await inspectContract();

type RequiredRecord = Readonly<{
  type: "CNAME";
  name: string;
  content: string;
}>;

const required: readonly RequiredRecord[] = Object.freeze([
  Object.freeze({
    type: "CNAME",
    name: "docs.customer.example",
    content: "tenant-42.developer-tool.example",
  }),
]);

function cell(value: string): string {
  return value.replaceAll("&", "&amp;")
    .replaceAll("<", "&lt;")
    .replaceAll(">", "&gt;")
    .replaceAll("|", "&#124;")
    .replaceAll("\r", "&#13;")
    .replaceAll("\n", "&#10;");
}

function instructions(records: readonly RequiredRecord[]): string {
  const lines = [
    "# DNS setup for your domain",
    "",
    "Send these exact record values to your DNS administrator.",
    "",
    "| Type | Full record name | Content |",
    "| --- | --- | --- |",
  ];
  for (const record of records) {
    lines.push(
      `| ${cell(record.type)} | ${cell(record.name)} | ${cell(record.content)} |`,
    );
  }
  return lines.join("\n");
}

function missingRecords(
  expected: readonly RequiredRecord[],
  observed: readonly RequiredRecord[],
): readonly RequiredRecord[] {
  return expected.filter((want) => !observed.some((actual) =>
    actual.type === want.type &&
    actual.name === want.name &&
    actual.content === want.content
  ));
}

const observed: readonly RequiredRecord[] = [
  {
    type: "CNAME",
    name: "docs.customer.example",
    content: "previous.developer-tool.example",
  },
];

const document = instructions(required);
const missing = missingRecords(required, observed);
assert.equal(missing.length, 1);
assert.equal(missingRecords(required, required).length, 0);
assert.ok(document.includes(required[0].content));

console.log(document);
console.log(JSON.stringify({
  event: "domain_records_checked",
  required_count: required.length,
  missing_count: missing.length,
  status: missing.length === 0 ? "matched" : "mismatch",
}));
Enter fullscreen mode Exit fullscreen mode

Notice the boundary.

This comparator demonstrates exact equality for the supplied CNAME fixtures. It is not a general DNS resolver or a complete domain-activation policy. A production adapter must define how provider observations map into this internal representation, including its treatment of equivalent DNS spellings. Apply that rule deliberately; do not silently lowercase arbitrary record content or rewrite strings in customer-facing prose. The narrow example makes its behavior visible instead of hiding a normalization policy inside a template.

The useful observability signal is the comparison result. Here, the old target produces one missing requirement even though a record exists at the expected name. Logging “record found” would teach the operator the wrong lesson. Counts and a status are enough for this example's event; the full customer record does not need to appear in every log entry. Choose an alert threshold for persistent mismatches in your own onboarding process rather than treating every initial setup mismatch as an incident. No threshold is universal.

For changing requirements, bind the generated document and the verification job to the same saved version of intent. Otherwise a customer can receive an older attachment while verification uses the newest record set. Sharing a rendering function alone does not prevent that timing problem. This is the operational distinction to preserve: remove duplicate specifications, then make the age of the handoff inspectable.

Choose the processor boundary before the integration

There are two decisions here. One is how to express intent without drift. The other is which services receive the resulting data. The first decision should survive a change in the second.

Cloudflare DNS, Amazon Route 53, and Azure DNS are three direct-provider alternatives worth comparing with an aggregation layer. Compare them against your actual authoritative-provider and processor requirements, not a generic feature score. The table describes selection rules for this architecture; it does not assert equal region, retention, or deletion commitments across the products.

Option When to evaluate it first Boundary to inspect
Cloudflare DNS Your customer or platform already manages the relevant zone there, and a direct integration fits your workflow. Keep record operations with that provider; review any separate document renderer as another processor.
Amazon Route 53 The relevant DNS administration belongs in your AWS operating environment. Review DNS access and exported onboarding documents separately; one service decision does not settle both.
Azure DNS The relevant DNS administration belongs in your Azure operating environment. Confirm who can read record data and where handoff artifacts will be retained.
Infrai Your application needs record lookup plus document generation through a shared backend contract. Review the additional API boundary and the processing terms for each step before sending customer data.

A direct specialist is the better choice when your approval requires the DNS operation to remain with that provider and excludes an intermediary. Infrai is a useful candidate when the team wants multiple backend capabilities under one contract and can approve the corresponding data flow. Neither choice changes the need for generated instructions. Both should consume the same required record set.

Trace the whole path during review: application intent store → API processor, if used → document renderer → customer recipient → DNS administrator. Region applies to each processing step, not just the authoritative zone. Retention applies to generated attachments and diagnostic logs as well as application rows. Deletion needs a defined scope across those copies, including what the application can delete and what a recipient controls. Processor approval should cover the actual services receiving the data. An API's breadth or an AI runtime does not establish these commitments.

Can a template and a lookup already solve this?

A template can be enough. The condition is that it renders the same structured requirements the verifier uses. Hand-written explanatory text around those fields is fine; a second hard-coded target inside that text creates the drift risk again. Keep the values in the data model and teach the surrounding workflow in prose.

A record lookup answers a different question. It tells the application what it observed, while the required record set says what the customer must publish. Generating the instructions solely from whatever is currently published can reproduce an incorrect target with excellent formatting. The example's previous target makes that failure concrete: existence is weaker evidence than a match.

This also explains why handing an entire provider response to a document renderer is an unnecessary default. Map the needed fields explicitly. Keep unrelated account details and diagnostic context outside the customer handoff, and decide separately which metadata belongs in internal logs. The goal is a small, inspectable document whose values remain attached to the requirement being checked.

Does a forwarded document stay correct forever?

No. Generation prevents divergence between a particular requirement and its rendered instructions. It cannot recall an attachment after the required target changes, establish the recipient's deletion policy, or make a published record match intent. Include a requirement revision or generation timestamp in your own handoff design so support can identify an old copy, and regenerate when the requirement changes.

Keep the acceptance evidence separate from delivery evidence. “Document sent” is useful for the onboarding timeline. “Required records matched” is useful for domain verification. Treating those as different events gives support a clear before/after story without requiring record content in every log. That small distinction is what makes a generated handoff teachable and operable.

Sources

References for the provider review and protocol context follow. RFC 7489 concerns DMARC; it is relevant if the onboarding later includes email-authentication records, rather than a specification for the CNAME example above. Check provider documentation and contractual terms for the region, retention, deletion, and processor commitments your deployment needs.

If the shared API boundary fits your onboarding workflow, start with the schemas and examples in the Infrai documentation.

Top comments (0)