Skip to content
This repository was archived by the owner on Mar 10, 2025. It is now read-only.

Latest commit

 

History

History
255 lines (134 loc) · 3.57 KB

File metadata and controls

255 lines (134 loc) · 3.57 KB

@ceramic-sdk/identifiers v0.2.0Docs


Ceramic SDK / @ceramic-sdk/identifiers / StreamID

Class: StreamID

Stream identifier, no commit information included.

Contains stream type and CID of genesis commit.

Encoded as <multibase-prefix><multicodec-streamid><type><genesis-cid-bytes>.

String representation is base36-encoding of the bytes above.

Constructors

new StreamID()

new StreamID(type, cid): StreamID

Create a new StreamID.

Parameters

type: StreamType

the stream type

cid: string | CID<unknown, number, number, Version>

Returns

StreamID

Example

new StreamID('MID', 'bagcqcerakszw2vsovxznyp5gfnpdj4cqm2xiv76yd24wkjewhhykovorwo6a');
new StreamID('MID', cid);
new StreamID(3, cid);

Properties

_tag

protected readonly _tag: symbol = TAG


fromBytes()

static fromBytes: (bytes) => StreamID

Parse StreamID from bytes representation.

Parameters

bytes: Uint8Array

bytes representation of StreamID.

Returns

StreamID

Throws

error on invalid input

See

StreamID#bytes


fromString()

static fromString: (input) => StreamID

Parse StreamID from string representation.

Parameters

input: string

string representation of StreamID, be it base36-encoded string or URL.

Returns

StreamID

See

  • StreamID#toString
  • StreamID#toUrl

Accessors

baseID

get baseID(): StreamID

Copy of self. Exists to maintain compatibility with CommitID.

Returns

StreamID

Defined in


bytes

get bytes(): Uint8Array

Bytes representation of StreamID.

Returns

Uint8Array

Defined in


cid

get cid(): CID<unknown, number, number, Version>

Genesis commits CID

Returns

CID<unknown, number, number, Version>

Defined in


type

get type(): StreamTypeCode

Stream type code

Returns

StreamTypeCode

Defined in


typeName

get typeName(): "tile" | "caip10-link" | "model" | "MID" | "UNLOADABLE"

Stream type name

Returns

"tile" | "caip10-link" | "model" | "MID" | "UNLOADABLE"

Defined in

Methods

equals()

equals(other): boolean

Compare equality with another StreamID.

Parameters

other: StreamID

Returns

boolean


toString()

toString(): string

Encode the StreamID into a string.

Returns

string


toUrl()

toUrl(): string

Encode the StreamID into a base36 url.

Returns

string


fromPayload()

static fromPayload(type, value): StreamID

Create a streamId from an init event payload.

Parameters

type: StreamType

the stream type

value: unknown

the init event payload

Returns

StreamID

Example

const streamId = StreamID.fromPayload('MID', {
  header: {
    controllers: ['did:3:kjz...'],
    model: '...',
  }
});

isInstance()

static isInstance(instance): instance is StreamID

Parameters

instance: unknown

Returns

instance is StreamID