or run

tessl search
Log in

Version

Files

tile.json

task.mdevals/scenario-7/

Integrity-Checked Asset Fetcher

Download remote assets while enforcing Subresource Integrity (SRI), emitting verification telemetry, and caching verified content for reuse.

Capabilities

Enforces integrity on downloads

  • Resolves when content matches the expected integrity string and returns the full body. @test
  • Rejects with an integrity verification error when the fetched content does not match the expected integrity. @test

Reports verification telemetry

  • Invokes the provided telemetry callback with emitted integrity and size details during a successful download. @test

Caches verified responses

  • Serves a verified response from cache on a repeated request without re-downloading when the integrity matches. @test

Implementation

@generates

API

export interface IntegrityFetchOptions {
  /** Absolute or relative URL to fetch. */
  url: string;
  /** Subresource Integrity string that incoming content must satisfy. */
  expectedIntegrity: string;
  /** Optional hash algorithms to allow during verification. */
  algorithms?: string[];
  /** Optional expected size, in bytes, for additional validation. */
  size?: number;
  /** Filesystem path where verified responses should be cached. */
  cachePath: string;
  /** Callback invoked for each integrity/size verification event. */
  onIntegrity?: (payload: { event: "integrity" | "size"; value: string | number }) => void;
}

export interface IntegrityFetchResult {
  /** HTTP status code returned by the request or cache. */
  status: number;
  /** Response body as a Buffer. */
  body: Buffer;
  /** True when the result originated from a cached, previously verified response. */
  fromCache: boolean;
}

/**
 * Fetches a resource while enforcing Subresource Integrity, emitting telemetry, and caching verified responses.
 */
export function fetchWithIntegrity(options: IntegrityFetchOptions): Promise<IntegrityFetchResult>;

Dependencies { .dependencies }

make-fetch-happen { .dependency }

Fetch-compatible HTTP client with built-in integrity verification, telemetry events, and cache support.

@satisfied-by