Creates an instance of this type by decoding it from tagged CBOR.
This method first verifies that the CBOR value has one of the expected
tags (as defined by cborTags()), then delegates to
fromUntaggedCbor() to decode the content.
For backward compatibility, this method accepts any tag from the
cborTags() array, not just the first one. This allows new
versions of types to still accept data tagged with older/alternative
tag values.
In most cases, you don't need to override this method.
Tagged CBOR value
Decoded instance
OptionalfromCreates an instance of this type by decoding it from binary encoded tagged CBOR.
This is a convenience method that first parses the binary data into a
CBOR value, then uses fromTaggedCbor() to decode it.
Binary CBOR data
Decoded instance
OptionalfromCreates an instance of this type by decoding it from binary encoded untagged CBOR.
This is a convenience method that first parses the binary data into a
CBOR value, then uses fromUntaggedCbor() to decode it.
Binary CBOR data
Decoded instance
Returns the CBOR tags associated with this type.
This method should return an array of tags in order of preference:
The first tag in the array is the "preferred" tag and will be used
when encoding values of this type via
CborTaggedEncodable.taggedCbor().
All tags in the array are considered equivalent for decoding. When
CborTaggedDecodable.fromTaggedCbor() is called, any tag in this
array will be accepted as valid for this type.
This design enables backward compatibility: you can introduce a new tag (placed first in the array) while still supporting older tags for decoding.
For standard CBOR tags, you can use predefined tag constants from the
tags module, or create custom tags with createTag().
Interface for types that can be decoded from CBOR with a specific tag.
This interface extends
CborTaggedto provide methods for decoding tagged CBOR data into TypeScript types. It handles verification that the CBOR data has the expected tag(s) and provides utilities for both tagged and untagged decoding.Example