Skip to content
Français

readStoredArtifact

import { readStoredArtifact } from "@elie-laloum/outpost";

Validate an untrusted reference, check its contract and any expected producer and parents, then load the bytes and verify their size and SHA-256 digest before decoding. Each mismatch rejects with an error naming it, such as Artifact contract mismatch. Use it outside a task, for example in another process.

Complete example and detailed rules.

  • storeRequired
    ArtifactStore
    Store holding the artifact bytes.
  • contractRequired
    ArtifactContract<T>
    Expected contract: its name, version and encoding must match the reference, and it decodes the bytes.
  • valueRequired
    unknown
    Reference to read, typically parsed from JSON. It is validated and its id recomputed before any bytes are loaded.
  • optionsOptional
    ReadArtifactOptions | undefined
    Expected producer and parents, and a cancellation signal.
  • options.producerOptional
    ArtifactProducer | undefined
    Expected execution, task key and attempt; any difference rejects with Artifact producer mismatch.
  • options.parentsOptional
    readonly ArtifactReference[] | undefined
    Expected parent references, in order; a different list rejects with Artifact lineage mismatch.
  • options.signalOptional
    AbortSignal | undefined
    Aborting it rejects the read with the signal’s reason.

Promise<T>

export declare function readStoredArtifact<T>(
  store: ArtifactStore,
  contract: ArtifactContract<T>,
  value: unknown,
  options?: ReadArtifactOptions,
): Promise<T>;