Common
constCommon:object
Defined in: astrobase/src/common/common.ts:37
A base InstanceConfig that provides implementations for all supported codecs, procedure handlers, hash algorithms, content identifier schemes, and wrap types.
This design enables a “batteries included” experience with minimal configuration, while also allowing unparalleled tree-shakability and customisation. Most applications will use the common config as a base, with additional configs extending or even overriding features. In special cases the config can not be imported into the application at all, instead allowing a custom configuration to load only the functionality needed and leaving base functionality to be tree-shaken.
Type declaration
Section titled “Type declaration”codecs
Section titled “codecs”
readonlycodecs:object
codecs.application/astrobase-wrap
Section titled “codecs.application/astrobase-wrap”
readonlyapplication/astrobase-wrap:Codec<Unwrapped<unknown,unknown>> =WrapCodec
codecs.application/json
Section titled “codecs.application/json”
readonlyapplication/json:Codec<unknown> =JsonCodec
codecs.application/octet-stream
Section titled “codecs.application/octet-stream”
readonlyapplication/octet-stream:Codec<Uint8Array<ArrayBufferLike>> =BinaryCodec
hashAlgs
Section titled “hashAlgs”
readonlyhashAlgs:object
hashAlgs.0
Section titled “hashAlgs.0”
readonly0:HashFn=sha256
procedures
Section titled “procedures”
readonlyprocedures:object
procedures.content:delete()
Section titled “procedures.content:delete()”
readonlycontent:delete: (cid,instance) =>Promise<void> =deleteContent
Invokes the content:delete procedure via all clients that support it.
Parameters
Section titled “Parameters”A valid ContentIdentifierLike value.
instance
Section titled “instance”The Instance config to use.
Returns
Section titled “Returns”Promise<void>
A promise that resolves once all requests are completed.
procedures.content:get()
Section titled “procedures.content:get()”
readonlycontent:get: <T>(cid,instance) =>Promise<undefined|T> =getContent
Retrieves an item of content.
Type Parameters
Section titled “Type Parameters”T
The type of the content after being parsed.
Parameters
Section titled “Parameters”A valid ContentIdentifierLike value.
instance
Section titled “instance”The instance to use for this request.
Returns
Section titled “Returns”Promise<undefined | T>
A promise that resolves with the parsed content, or undefined if nothing acceptable
was found.
procedures.content:put()
Section titled “procedures.content:put()”
readonlycontent:put: (req,instance) =>Promise<void>
Parameters
Section titled “Parameters”any
instance
Section titled “instance”Required<InstanceConfig>
Returns
Section titled “Returns”Promise<void>
schemes
Section titled “schemes”
readonlyschemes:object
schemes.$mut
Section titled “schemes.$mut”
readonly$mut:ContentIdentifierSchemeParser<FileBuilder<unknown>> =parseAsFile
schemes.$pub
Section titled “schemes.$pub”
readonly$pub:ContentIdentifierSchemeParser<Identity> =identityScheme
schemes.$ref()
Section titled “schemes.$ref()”
readonly$ref: (cid,content,instance) =>Promise<undefined|FileBuilder<unknown>> =Immutable
Parameters
Section titled “Parameters”content
Section titled “content”Uint8Array<ArrayBufferLike>
instance
Section titled “instance”Required<InstanceConfig>
Returns
Section titled “Returns”Promise<undefined | FileBuilder<unknown>>
readonlywraps:object
wraps.ECDSA
Section titled “wraps.ECDSA”ECDSA:
WrapModule<ECDSAWrappedMetadata,ECDSAUnwrappedMetadata>
wraps.encrypt
Section titled “wraps.encrypt”
readonlyencrypt:WrapModule<EncryptWrapMetadata,EncryptWrapMetadata> =EncryptWrapModule
Example
Section titled “Example”import { Common } from '@astrobase/sdk/common'; import { createInstance } from '@astrobase/sdk/instance';
const instance = createInstance(Common);