Blockchain Commons XID TypeScript Library - v1.0.0-alpha.13
    Preparing search index...

    Class XID

    @bcts/xid - XID Document Library

    TypeScript implementation of Blockchain Commons' XID specification for eXtensible IDentifiers and XID Documents.

    Ported from bc-xid-rust

    Implements

    • CborTaggedEncodable
    • CborTaggedDecodable<XID>
    • UREncodable
    Index

    Properties

    XID_SIZE: 32

    Methods

    • Create a new XID from data.

      Parameters

      • data: Uint8Array

      Returns XID

    • Create a new XID from data (validates length).

      Returns error if the data is not the correct length.

      Parameters

      • data: Uint8Array

      Returns XID

    • Create an XID from raw bytes (legacy alias).

      Parameters

      • data: Uint8Array

      Returns XID

    • Create an XID from hex string (64 hex characters).

      Parameters

      • hex: string

      Returns XID

    • Generate a random XID (for testing purposes).

      Note: In practice, XIDs should be created from the SHA-256 hash of a public signing key's CBOR encoding.

      Returns XID

    • Return the data of the XID.

      Returns Uint8Array

    • Get the data of the XID as a byte slice.

      Returns Uint8Array

    • Get a copy of the raw XID bytes.

      Returns Uint8Array

    • Get hex string representation (lowercase, matching Rust implementation).

      Returns string

    • Get base64 representation.

      Returns string

    • Get short description (first 4 bytes) as hex.

      Returns string

    • Get short reference (first 4 bytes) as hex (alias for shortDescription).

      Returns string

    • Get the first four bytes of the XID as upper-case ByteWords.

      Parameters

      • Optionalprefix: boolean

        If true, prepends the XID prefix "🅧 "

      Returns string

      Space-separated uppercase bytewords, e.g., "🅧 URGE DICE GURU IRIS"

    • Get the first four bytes of the XID as Bytemoji.

      Parameters

      • Optionalprefix: boolean

        If true, prepends the XID prefix "🅧 "

      Returns string

      Space-separated emojis, e.g., "🅧 🐻 😻 🍞 💐"

    • Compare with another XID.

      Parameters

      Returns boolean

    • Get string representation.

      Returns string

    • Returns the CBOR tags associated with XID.

      Returns Tag[]

    • Returns the untagged CBOR encoding (as a byte string).

      Returns Cbor

    • Returns the tagged CBOR encoding.

      Returns Cbor

    • Returns the tagged value in CBOR binary representation.

      Returns Uint8Array

    • Creates a XID by decoding it from untagged CBOR.

      Parameters

      • cbor: Cbor

      Returns XID

    • Creates a XID by decoding it from tagged CBOR.

      Parameters

      • cbor: Cbor

      Returns XID

    • Static method to decode from tagged CBOR.

      Parameters

      • cbor: Cbor

      Returns XID

    • Static method to decode from tagged CBOR binary data.

      Parameters

      • data: Uint8Array

      Returns XID

    • Static method to decode from untagged CBOR binary data.

      Parameters

      • data: Uint8Array

      Returns XID

    • Returns the UR representation of the XID. Note: URs use untagged CBOR since the type is conveyed by the UR type itself.

      Returns UR

    • Returns the UR string representation.

      Returns string

    • Creates a XID from a UR.

      Parameters

      • ur: UR

      Returns XID

    • Creates a XID from a UR string.

      Parameters

      • urString: string

      Returns XID