did-btcr2-js

ADR 023: CAS Read Path: Helia vs HTTP Gateway

Status: Accepted

Date: 2026-04-10

Commit: 8fe1404

Context

The CAS beacon announces off-chain Announcement objects keyed by their SHA-256 content hash. Resolvers must retrieve those announcements to process the beacon signal. Two sensible transport choices exist:

Wallet webapps and interactive resolvers need fast, lightweight retrieval. Long-running CLIs and service operators might prefer a full Helia node. Both use cases must be supportable without forcing either.

Options considered

  1. Helia-only. Strong decentralization story; unusable in most browser contexts.
  2. HTTP-gateway-only. Trivial implementation; loses the decentralized narrative completely.
  3. Pluggable CasExecutor interface: two default implementations (Helia, HTTP gateway): consumer picks.

Decision

Option 3. Introduce CasExecutor interface in @did-btcr2/api/src/cas.ts:

interface CasExecutor {
  retrieve(hash: string): Promise<Uint8Array | null>;
  publish(data: Uint8Array): Promise<string>;
}

Two default implementations ship:

Consumer chooses by constructing the appropriate executor and passing it into Api.cas. The resolver doesn’t know or care which implementation is in use.

Default fallback when no CAS is configured: HTTP gateway (the lightweight default fits the wallet / browser scenario and degrades gracefully if the gateway is down: the error is visible).

Consequences

Positive

Negative

Explicitly accepted trade-offs

References