Class: CasApi ​
Defined in: packages/api/src/cas.ts:82
Content-Addressed Storage API sub-facade.
Provides publish and retrieve for JSON objects using their JCS-canonicalized SHA-256 hash as the content address.
By default uses IPFS (via Helia). Inject a custom CasExecutor to use a different CAS backend.
Lazily initialized by DidBtcr2Api to avoid startup overhead when CAS features are not used.
Constructors ​
Constructor ​
new CasApi(
config):CasApi
Defined in: packages/api/src/cas.ts:85
Parameters ​
config ​
Returns ​
CasApi
Methods ​
publish() ​
publish(
object):Promise<string>
Defined in: packages/api/src/cas.ts:117
Publish a JSON object to the CAS. The object is JCS-canonicalized before storage; the returned hash matches what canonicalHash would produce.
Parameters ​
object ​
object
The JSON object to publish.
Returns ​
Promise<string>
The base64url-encoded SHA-256 hash (content address).
retrieve() ​
retrieve(
hash):Promise<object|null>
Defined in: packages/api/src/cas.ts:103
Retrieve a JSON object from the CAS by its base64url SHA-256 hash.
Parameters ​
hash ​
string
Base64url-encoded SHA-256 hash of the JCS-canonicalized object.
Returns ​
Promise<object | null>
The parsed JSON object, or null if not found.