@blockchaincommons/xid - v1.0.0-beta.3
    Preparing search index...

    Class XIDDocument

    A XID document: the keys, delegates, services, resolution methods, provenance, attachments and edges published under an extensible identifier. The document is mutable; its keys, delegates and services are copied-out arrays of live values, and attachments and edges() are the document's own containers.

    Implements

    • ToEnvelope
    • ToCbor
    • CborTagged
    • ToUR
    • Edgeable
    Index
    • get reference(): Reference

      The XID's reference.

      Returns Reference

    • get isEmpty(): boolean

      No keys, delegates, services, resolution methods, provenance, attachments, edges or extra assertions.

      Returns boolean

    • get extraAssertions(): readonly Envelope[]

      Assertions the parser did not recognise, kept as they were (a copy).

      Returns readonly Envelope[]

    • get resolutionMethods(): ReadonlySet<URI>

      The resolution methods (a copy).

      Returns ReadonlySet<URI>

    • get keys(): readonly Key[]

      The keys (a copied-out array of live keys).

      Returns readonly Key[]

    • get inceptionKey(): Key | undefined

      The key whose signing key the XID derives from.

      Returns Key | undefined

    • get inceptionPrivateKeys(): PrivateKeys | undefined

      The inception key's private keys, when held in the clear.

      Returns PrivateKeys | undefined

    • get inceptionSigningKey(): SigningPublicKey | undefined

      The inception key's signing key.

      Returns SigningPublicKey | undefined

    • get verificationKey(): SigningPublicKey | undefined

      The inception key's signing key, else the first key's.

      Returns SigningPublicKey | undefined

    • get encryptionKey(): EncapsulationPublicKey | undefined

      The inception key's encapsulation key, else the first key's.

      Returns EncapsulationPublicKey | undefined

    • get attachments(): Attachments

      The attachments: the document's own container.

      Returns Attachments

    • get hasAttachments(): boolean

      Whether there are attachments.

      Returns boolean

    • get provenance(): ProvenanceMark | undefined

      The current provenance mark.

      Returns ProvenanceMark | undefined

    • get provenanceGenerator(): ProvenanceMarkGenerator | undefined

      The generator when the document holds it in the clear.

      Returns ProvenanceMarkGenerator | undefined

    • A document whose XID derives from the inception key's signing key; the key is added allowed All. A genesis mark starts the provenance chain and keeps the generator in the document. A missing inception key or a malformed genesis is a TypeError; a seed of the wrong length is ProvenanceMark.

      Parameters

      Returns XIDDocument

    • Adds a resolution method, as a URI or its text (a components error for text that is not a URI).

      Parameters

      • method: string | URI

      Returns void

    • Removes and returns a resolution method; undefined when it was not there.

      Parameters

      • method: string | URI

      Returns URI | undefined

    • Adds a key; Duplicate when the public keys are already there.

      Parameters

      Returns void

    • The key with these public keys.

      Parameters

      • publicKeys: PublicKeys

      Returns Key | undefined

    • The key with this reference.

      Parameters

      • reference: Reference

      Returns Key | undefined

    • Removes and returns the key; StillReferenced when a service names it, NotFound when it is not there.

      Parameters

      • publicKeys: PublicKeys

      Returns Key

    • Removes and returns the key without checking services; undefined when absent.

      Parameters

      • publicKeys: PublicKeys

      Returns Key | undefined

    • KeyNotFoundInDocument unless the key with these public keys is there.

      Parameters

      • publicKeys: PublicKeys

      Returns void

    • Whether the XID derives from this signing key.

      Parameters

      • signingPublicKey: SigningPublicKey

      Returns boolean

    • Removes and returns the inception key, if there is one.

      Returns Key | undefined

    • Sets the key's nickname; NotFound unless the key is there.

      Parameters

      • publicKeys: PublicKeys
      • name: string

      Returns void

    • The private keys of a key as an envelope (see Key.privateKeyEnvelope).

      Parameters

      Returns Envelope | undefined

    • The inception key's private keys of a parsed envelope, unlocked with the password.

      Parameters

      Returns PrivateKeys | undefined

    • Adds a delegate; Duplicate when a delegate with that XID is already there.

      Parameters

      Returns void

    • The delegate whose XID has this reference.

      Parameters

      • reference: Reference

      Returns Delegate | undefined

    • Removes and returns the delegate; StillReferenced when a service names it, NotFound when absent.

      Parameters

      • xid: XID

      Returns Delegate

    • Removes and returns the delegate without checking services; undefined when absent.

      Parameters

      • xid: XID

      Returns Delegate | undefined

    • DelegateNotFoundInDocument unless the delegate with this XID is there.

      Parameters

      • xid: XID

      Returns void

    • The service at this URI.

      Parameters

      • uri: string | URI

      Returns Service | undefined

    • Adds a service; Duplicate when a service at that URI is already there.

      Parameters

      Returns void

    • Removes and returns the service; undefined when absent.

      Parameters

      • uri: string | URI

      Returns Service | undefined

    • Removes and returns the service; NotFound when absent.

      Parameters

      • uri: string | URI

      Returns Service

    • Every service references known keys and delegates and allows something.

      Returns void

    • NoReferences without any key or delegate reference, UnknownKeyReference/UnknownDelegateReference for one the document lacks, NoPermissions without an allowed privilege.

      Parameters

      Returns void

    • Whether any service references this key.

      Parameters

      • publicKeys: PublicKeys

      Returns boolean

    • Whether any service references this delegate.

      Parameters

      • xid: XID

      Returns boolean

    • The attachment with this digest.

      Parameters

      • digest: Digest

      Returns Envelope | undefined

    • Removes and returns the attachment with this digest.

      Parameters

      • digest: Digest

      Returns Envelope | undefined

    • Removes every attachment.

      Returns void

    • The edges: the document's own container (envelope's Edgeable).

      Returns Edges

    • The same container as edges() (envelope's Edgeable names both).

      Returns Edges

    • Whether there are edges (envelope's Edgeable).

      Returns boolean

    • Adds an edge envelope.

      Parameters

      • edgeEnvelope: Envelope

      Returns void

    • The edge with this digest (envelope's Edgeable).

      Parameters

      • digest: Digest

      Returns Envelope | undefined

    • Removes and returns the edge with this digest.

      Parameters

      • digest: Digest

      Returns Envelope | undefined

    • Removes every edge.

      Returns void

    • Sets (or clears) the mark, dropping any generator.

      Parameters

      • provenance: ProvenanceMark | undefined

      Returns void

    • Sets the mark and the generator that continues its chain.

      Parameters

      • generator: ProvenanceMarkGenerator
      • mark: ProvenanceMark

      Returns void

    • Advances the chain with the document's own generator, unlocked with the password when it is locked; the generator stays in the document. NoProvenanceMark without a mark, NoGenerator without a generator, InvalidPassword when it is locked and the password is missing or wrong, ChainIdMismatch/SequenceMismatch when the generator does not continue the mark at the next sequence number; a Date without a time is ProvenanceMark[InvalidDate]; a date of another kind is a TypeError.

      Parameters

      Returns void

    • Advances the chain with a generator the caller keeps; the generator is advanced in place and not stored. NoProvenanceMark without a mark, GeneratorConflict when the document holds a generator (in the clear or locked), ChainIdMismatch/SequenceMismatch when the generator does not continue the mark at the next sequence number; a Date without a time is ProvenanceMark[InvalidDate]; a generator or date of another kind is a TypeError.

      Parameters

      Returns void

    • The XID as the subject; 'dereferenceVia', 'key', 'delegate', 'service', 'provenance', the extra assertions, attachments and edges; then signed per sign (MissingInceptionKey when the inception key or its private keys are missing). An unknown option is a TypeError.

      Parameters

      Returns Envelope

    • A document from its envelope. With verify: "inception" the envelope must be signed by the document's own inception key (EnvelopeNotSigned, SignatureVerificationFailed, InvalidXid); otherwise a wrapped (signed) subject is unwrapped and read as it is. The password unlocks locked private keys and generators. Every failure is an XIDError: a sibling error inside the parser is wrapped with the reference's code. An unknown verify is a TypeError.

      Parameters

      Returns XIDDocument

    • An empty document is its XID's bytes; otherwise the envelope's tagged CBOR.

      Returns Cbor

    • Tag xid (40024) over untaggedCbor.

      Returns Cbor

    • The tags this document's CBOR carries: xid (40024).

      Returns Tag[]

    • A document from its tagged CBOR: the xid tag (40024) over the untagged form. A missing or different tag, or a form the untagged decoder rejects, is Cbor with the dcbor error's message.

      Parameters

      • cborValue: Cbor

      Returns XIDDocument

    • A document from its untagged CBOR: a 32-byte string is the XID of an empty document; anything else is a document envelope. A tagged value is rejected (the envelope tag is expected), as the reference's from_untagged_cbor rejects it. A rejection is Cbor: the dcbor error's message, or the document error's (envelope parsing error, …) when the envelope decodes but the document does not.

      Parameters

      • cborValue: Cbor

      Returns XIDDocument

    • ur:xid/… over untaggedCbor.

      Returns UR

    • A document from a ur:xid/… UR. A UR of another type is Cbor (expected UR type xid, but found …), as the reference's from_ur reports it.

      Parameters

      • ur: UR

      Returns XIDDocument

    • Same XID, resolution methods, keys (public and private material, nickname, endpoints, permissions), delegates, services, provenance (mark and generator), attachments, edges and extra assertions — as the reference's equality.

      Parameters

      Returns boolean