Defined in: packages/cas/src/artifact.ts:54
A store that names artifacts by the hash of their framing bytes.
Properties
Section titled “Properties”addressOf
Section titled “addressOf”
readonlyaddressOf: (artifact) =>string
Defined in: packages/cas/src/artifact.ts:62
Address the artifact would receive, without writing it. O(bytes); pure.
Parameters
Section titled “Parameters”artifact
Section titled “artifact”Returns
Section titled “Returns”string
Throws
Section titled “Throws”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.
readonlyadd: (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).
Parameters
Section titled “Parameters”artifact
Section titled “artifact”Returns
Section titled “Returns”Promise<string>
Throws
Section titled “Throws”As addressOf, plus BACKEND_FAILURE
when the backend throws.
Throws
Section titled “Throws”With ADDRESS_COLLISION when the address is present
but holds different bytes, which means the injected hash mapped two
artifacts to one address.
readonlyhas: (address) =>Promise<boolean>
Defined in: packages/cas/src/artifact.ts:80
Whether address holds an artifact. O(1) expected, plus one validation.
Parameters
Section titled “Parameters”address
Section titled “address”string
Returns
Section titled “Returns”Promise<boolean>
Throws
Section titled “Throws”With INVALID_ADDRESS when the address is
not a safe storage key, or BACKEND_FAILURE when the backend throws.
readonlyget: (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.
Parameters
Section titled “Parameters”address
Section titled “address”string
Returns
Section titled “Returns”Promise<WireEnvelope | undefined>
Throws
Section titled “Throws”With INVALID_ADDRESS when the address is
not a safe storage key, or BACKEND_FAILURE when the backend throws.
Throws
Section titled “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.