Skip to content

Defined in: packages/cas/src/artifact.ts:54

A store that names artifacts by the hash of their framing bytes.

readonly addressOf: (artifact) => string

Defined in: packages/cas/src/artifact.ts:62

Address the artifact would receive, without writing it. O(bytes); pure.

Artifact

string

With INVALID_ARTIFACT when the artifact cannot be framed, INVALID_HASH when the hash does not return an address-shaped string, or HASH_FAILURE when the hash throws.


readonly add: (artifact) => Promise<string>

Defined in: packages/cas/src/artifact.ts:73

Frame the artifact, then store it under its address unless the same bytes are already there. Returns the address. O(bytes).

Artifact

Promise<string>

As addressOf, plus BACKEND_FAILURE when the backend throws.

With ADDRESS_COLLISION when the address is present but holds different bytes, which means the injected hash mapped two artifacts to one address.


readonly has: (address) => Promise<boolean>

Defined in: packages/cas/src/artifact.ts:80

Whether address holds an artifact. O(1) expected, plus one validation.

string

Promise<boolean>

With INVALID_ADDRESS when the address is not a safe storage key, or BACKEND_FAILURE when the backend throws.


readonly get: (address) => Promise<WireEnvelope | undefined>

Defined in: packages/cas/src/artifact.ts:95

Read and verify the artifact stored under address, or undefined when the address is absent. O(bytes).

The bytes are re-hashed before decoding, so a backend that returned the wrong content, or a hash that stopped being deterministic, fails as ADDRESS_MISMATCH rather than as a payload that happens to decode.

string

Promise<WireEnvelope | undefined>

With INVALID_ADDRESS when the address is not a safe storage key, or BACKEND_FAILURE when the backend throws.

With ADDRESS_MISMATCH when the stored bytes do not hash to their address, or with any knotkit/wire failure the envelope raises under this store’s magic.