Represents the ephemeral, modifiable state used by the pipeline.

  • Mutable: Evolves as you walk the plugin chain.
  • Shared Data: Allows plugins to communicate partial results, discovered data, or interim errors.
  • Ephemeral: Typically discarded once fetch(...) completes.
interface PluginContext {
    accept?: string;
    byteRangeContext?: ByteRangeContext;
    cid: CID<unknown, number, number, Version>;
    directoryEntries?: UnixFSEntry[];
    errors?: PluginError[];
    ipfsPath: string;
    isDirectory?: boolean;
    modified: number;
    options?: Omit<VerifiedFetchInit, "signal"> & AbortOptions;
    path: string;
    pathDetails?: PathWalkerResponse;
    protocol: "ipns" | "ipfs";
    query: ParsedUrlQuery;
    reqFormat?: RequestFormatShorthand;
    resource: string;
    serverTimings: ServerTimingResult<any>[];
    ttl?: number;
    withServerTiming?: boolean;
    onProgress?(evt): void;
    [key: string]: unknown;
}

Hierarchy

Indexable

[key: string]: unknown

Properties

accept?: string
byteRangeContext?: ByteRangeContext

ByteRangeContext contains information about the size of the content and range requests. This can be used to set the Content-Length header without loading the entire body.

This is set by the ByteRangeContextPlugin

cid: CID<unknown, number, number, Version>
directoryEntries?: UnixFSEntry[]
errors?: PluginError[]
ipfsPath: string

The value for the IPFS gateway spec compliant header X-Ipfs-Path on the response. The value of this header should be the original requested content path, prior to any path resolution or traversal.

isDirectory?: boolean
modified: number

The last time the context is modified, so we know whether a plugin has modified it. A plugin should increment this value if it modifies the context.

options?: Omit<VerifiedFetchInit, "signal"> & AbortOptions
path: string
pathDetails?: PathWalkerResponse
protocol: "ipns" | "ipfs"
resource: string
serverTimings: ServerTimingResult<any>[]

serverTiming items

ttl?: number

seconds as a number

withServerTiming?: boolean

Methods