import { type IFormat } from "https://deno.land/x/earthstar@v10.2.0/src/entries/npm.ts";
Formats are each responsible for one document format such as "es.4". They are used for signing and validating documents, as well as generating new documents from a given input.
Type Parameters
Properties
The string name of the format, like "es.4"
Methods
Deterministic hash of this version of the document
Generate a signed document from the input format the validator expects.
Sign an unsigned document.
Overwrite the user-written contents of a document, wipes any associated attachments, and signs the document.
Return a copy of the doc without extra fields, plus the extra fields as a separate object. If the input is not a plain javascript object, return a ValidationError. This should be run before checkDocumentIsValid. The output doc will be more likely to be valid once the extra fields have been removed.
This calls all the more detailed functions which start with underscores. Returns true if the document is ok.
Returns information about a doc's attachment, if it has one. If it doesn't, a ValidationError
will be returned. This does not indicate if that attachment is actually present locally.
Some information can only be known once an attachment (especially if it comes in the form of a stream) has been consumed. For this reason, a Formatter's generateDocument
method may not be able to generate a valid document for a attachment, even if it already knows it has one.