Skip to content

Common

const Common: 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.

readonly codecs: object

readonly application/astrobase-wrap: Codec<Unwrapped<unknown, unknown>> = WrapCodec

readonly application/json: Codec<unknown> = JsonCodec

readonly application/octet-stream: Codec<Uint8Array<ArrayBufferLike>> = BinaryCodec

readonly hashAlgs: object

readonly 0: HashFn = sha256

readonly procedures: object

readonly content:delete: (cid, instance) => Promise<void> = deleteContent

Invokes the content:delete procedure via all clients that support it.

ContentIdentifierLike

A valid ContentIdentifierLike value.

Instance

The Instance config to use.

Promise<void>

A promise that resolves once all requests are completed.

readonly content:get: <T>(cid, instance) => Promise<undefined | T> = getContent

Retrieves an item of content.

T

The type of the content after being parsed.

ContentIdentifierLike

A valid ContentIdentifierLike value.

Instance

The instance to use for this request.

Promise<undefined | T>

A promise that resolves with the parsed content, or undefined if nothing acceptable was found.

readonly content:put: (req, instance) => Promise<void>

any

Required<InstanceConfig>

Promise<void>

readonly schemes: object

readonly $mut: ContentIdentifierSchemeParser<FileBuilder<unknown>> = parseAsFile

readonly $pub: ContentIdentifierSchemeParser<Identity> = identityScheme

readonly $ref: (cid, content, instance) => Promise<undefined | FileBuilder<unknown>> = Immutable

ContentIdentifier

Uint8Array<ArrayBufferLike>

Required<InstanceConfig>

Promise<undefined | FileBuilder<unknown>>

readonly wraps: object

ECDSA: WrapModule<ECDSAWrappedMetadata, ECDSAUnwrappedMetadata>

readonly encrypt: WrapModule<EncryptWrapMetadata, EncryptWrapMetadata> = EncryptWrapModule

import { Common } from '@astrobase/sdk/common';
import { createInstance } from '@astrobase/sdk/instance';
const instance = createInstance(Common);