Adam BlansettSenior Full-Stack & AI Engineer
Developer Tools & StartersActive Open-Source Release v0.1.0 (MIT)

API Contract Tester

Security-hardened TypeScript CLI and library for declarative HTTP contract validation, chained workflows, OpenAPI import, and mock servers.

Engineering RoleCreator & Lead Maintainer

01. Problem & Context

Frontend and backend teams routinely break production integrations through subtle status code changes, missing headers, type drift in nested JSON responses, or slow/unsafe HTTP test runners that leak Bearer tokens into CI logs or follow SSRF redirects.

02. Engineering Solution

Developed `api-contract-tester`, a declarative HTTP contract testing CLI and library built with Zod, Ajv (`ajv-formats`), and defense-in-depth HTTP security. Executes single or variable-chained HTTP assertions, imports OpenAPI 3.0/3.1 specs, serves an offline mock server from contract definitions, and enforces SSRF, CRLF, prototype-pollution, Slowloris, and secret-redaction shields.

03. System Architecture

Declarative JSON contract suites (`$schema`, `config`, `tests`) are validated offline with zero network I/O (`validate`), executed sequentially (when `capture` chaining is active) or via bounded concurrency (`--concurrency`), and reported in ANSI Terminal, JSON (`schemaVersion: 1.0.0`), JUnit XML, or GitHub Step Summaries.

Core Architectural Components

Declarative Contract Engine & Chained Variable Capture

Validates status codes/classes (`2xx`, `4xx`), required/prohibited headers, `Content-Type`, Ajv JSON Schemas, nested property paths (`items[0].sku`), regex matches, numeric bounds, array constraints, and `maxResponseTimeMs` latency thresholds with downstream `capture` variable injection.

Defense-in-Depth HTTP & SSRF Shield (`--block-private-networks`)

Enforces relative paths preserving `baseUrl` prefixes, rejects userinfo credentials and CRLF header injections, defends against prototype pollution (`Object.create(null)`), gates `POST`/`PUT`/`PATCH`/`DELETE` behind `--allow-destructive`, and blocks loopback, RFC1918, metadata, NAT64/6to4/hex-IPv4 via an 8-word IPv6 normalizer plus restricted WHATWG ports.

OpenAPI 3.x Importer, Mock Server & Schema Exporter

Scaffolds contracts via `import-openapi`, runs an offline `mock` HTTP server (5 MB payload cap) directly from contract files, exports IDE schemas via `export-schema`, and previews `--dry-run` / `--curl` commands without network calls.

Zero-Leak Secret Redaction & Slowloris Defense

Masks auth headers, query secrets, captured tokens, JWTs (`[REDACTED_JWT]`), AWS keys, and PEM keys across logs, JSON, JUnit XML, and stack traces while enforcing full-lifecycle streaming timeouts and 5 MB body caps.

04. Notable Engineering Decisions

Mathematical 8-Word IPv6 Normalization & Redirect Stream Cleanup

Naive string checks miss `::ffff:7f00:1`, NAT64 (`64:ff9b::/96`), or 6to4 SSRF bypasses. Normalizing DNS-resolved IPs mathematically and cancelling intermediate redirect streams prevents both SSRF and socket leaks.

Destructive Method Gate & Zero-I/O Spec Validation

Blocking mutating HTTP methods unless `--allow-destructive` is set and guaranteeing 0 network calls during `validate` keeps untrusted contract files safe in CI.

Auto-Redacting Dynamically Captured Session Secrets

Chained auth tests capture live tokens (`capture: { AUTH_TOKEN: 'body.token' }`). Registering captured values automatically in the redactor guarantees tokens never appear in JUnit XML or failure diffs.

05. Engineering Challenges & Solutions

Challenge: Defeating HTTP response splitting, ReDoS patterns, and Slowloris streaming hangs in an automated contract runner.

Engineering Solution: Added RFC 9110 header token validation, regex string/pattern length caps (64 KB / 1,000 chars), and `AbortController` timeouts covering full response body streaming.

Challenge: Lowering adoption friction for teams with existing OpenAPI specs or offline frontend tests.

Engineering Solution: Built `import-openapi` to bootstrap contracts from OpenAPI 3.0/3.1 YAML/JSON and an integrated `mock` server to serve contract responses locally.

06. Implementation Highlights

  • Declarative Zod + Ajv contract testing with chained `capture` variables, latency thresholds, regex, numeric, and array assertions
  • `import-openapi` (OpenAPI 3.0/3.1), offline `mock` server, `export-schema`, `--dry-run`/`--curl`, `-k` filtering, and `-w` watch mode
  • SSRF shield (`--block-private-networks`) with 8-word IPv6 normalizer, relative-path prefix sandboxing, and `--allow-destructive` gate
  • CRLF header guard, `Object.create(null)` prototype-pollution defense, ReDoS bounds, 5 MB streaming cap, and full-lifecycle timeouts
  • Zero-leak masking of JWTs, AWS keys, PEM keys, auth headers, and captured tokens across Terminal, JSON, JUnit XML, and GitHub Step Summaries
  • Verified across 15 Vitest test files (66 passing tests) and Node 20.x/22.x GitHub Actions CI