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.

Hierarchy

  • StreamID

Implements

Constructors

  • Create a new StreamID.

    Example

    new StreamID('tile', 'bagcqcerakszw2vsovxznyp5gfnpdj4cqm2xiv76yd24wkjewhhykovorwo6a');
    new StreamID('tile', cid);
    new StreamID(0, cid);

    Parameters

    • type: string | number

      the stream type

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

    Returns StreamID

Properties

_tag: symbol = TAG
fromBytes: ((bytes: Uint8Array) => StreamID) = fromBytes

Type declaration

    • (bytes: Uint8Array): StreamID
    • Parse StreamID from bytes representation.

      Throws

      error on invalid input

      See

      StreamID#bytes

      Parameters

      • bytes: Uint8Array

        bytes representation of StreamID.

      Returns StreamID

fromBytesNoThrow: ((bytes: Uint8Array) => StreamID | Error) = fromBytesNoThrow

Type declaration

    • (bytes: Uint8Array): StreamID | Error
    • Same as fromBytes, but returns an Error instance rather than throwing if there is a problem with the input. Note that some exceptions can still be thrown in certain cases, if they come from lower-level libraries like multibase, for example.

      Parameters

      • bytes: Uint8Array

      Returns StreamID | Error

fromString: ((input: string) => StreamID) = fromString

Type declaration

    • (input: string): StreamID
    • Parse StreamID from string representation.

      See

      • StreamID#toString
      • StreamID#toUrl

      Parameters

      • input: string

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

      Returns StreamID

fromStringNoThrow: ((input: string) => StreamID | Error) = fromStringNoThrow

Type declaration

    • (input: string): StreamID | Error
    • Same as fromString but returns an Error instance rather than throwing if there is a problem with the input. Note that some exceptions can still be thrown in certain cases, if they come from lower-level libraries like multibase, for example.

      Parameters

      • input: string

      Returns StreamID | Error

Accessors

Methods

  • Create a streamId from a genesis commit.

    Example

    const streamId = StreamID.fromGenesis('tile', {
    header: {
    controllers:['did:3:kjz...'],
    family: 'IDX'
    }
    });

    Parameters

    • type: string | number

      the stream type

    • genesis: Record<string, any>

      a genesis commit

    Returns Promise<StreamID>