OpenSheaf Explorer, a literate program
Draft. OpenSheaf 0.2 is a draft specification: until version 1.0, a revision may change the format in incompatible ways, and the explorer follows the latest draft. It reads archives of version 0.2 only; an archive of version 0.1 is told to be rebuilt.
This is the source of the OpenSheaf Explorer,
a web application that explores and verifies
OpenSheaf archives and collections from a browser,
written as a literate program. An OpenSheaf archive is a folder of static
files: an OCFL storage root in which every work is a
line, the history decided by one owner, whose versions the owner signs
with Ed25519 keys; every version fixed by SHA-512 digests and described by
DataCite metadata; works and owners named by
digests of their genesis records, the same in every archive; owners with
key logs that check themselves from their names; collections that pin
lines of any archive; a discovery document, opensheaf.json, that makes
it all findable. Since everything is a file that any reader can fetch,
and checks against names, digests and signatures, a browser can read an
archive, show it, and check it against the specification, with nothing
installed, no server of its own, and no trust in where the files come
from.
The explorer does four things:
- it shows an archive: its discovery document, its lines, each with its
sheaf:URI, its owner, every object version with the status of its signatures and its pin, every document version in the order of its history, its descriptions, notices, withdrawal, branch points, relations, licences and files; - it shows owners: their key logs, current and exposed keys, and whether they have ended, by an ending version or by a fork of their key logs;
- it shows collections, in their order, with their pins or revision sets, resolving members wherever their copies are, with the statuses of section 8.5, and following member collections, down to a depth limit;
- it verifies an archive: the checks of section 14 of the specification
that can be made over HTTP, in agreement, finding by finding, with
osheaf verify, the verifier of the reference implementation opensheaf-py, whose chapters this one follows and cites.
It is plain JavaScript: ES modules that the browser loads as they are, with no framework, no build step and no library, not even from a CDN; digests come from the browser's WebCrypto, and Ed25519 signatures are verified by a small verifier of its own, the same in every browser; the JSON Schemas of the specification are checked by a validator of its own. Everything it reads is untrusted, and it never puts anything it reads into the page as HTML.
The files of the application (index.html, app/*.js, style.css,
embed.js) and its tests are tangled out of these documents and kept in
the repository, so that the application is served as it stands; the
documents are also woven into this website. One edits the documents,
never the files. The tangler and the weaver are a package of their own,
opensheaf-literate (the literate
command), written for OpenSheaf and itself a literate program: its chapters
explain the syntax of these documents and
tangling, and
weaving. This project pins
a version of it in requirements-literate.txt and describes itself to it
in literate.json; literate tangle --where FILE:LINE tells which line of
which chapter a line of a tangled file comes from. The JSON Schemas in
schemas/ and the symbol opensheaf-symbol.svg are copies of the
specification's own files.
Reading the code
Code is set in grey boxes. Above each box stands the name of its chunk,
with ≡ for the first fragment of a chunk and +≡ for the ones that
continue it; a name in angle brackets inside the code, like
⟨the limits of the explorer⟩, is a reference to another chunk, and a link
to it. Below each box: where the chunk is used, and where it continues.
The index of chunks lists them all. Sections of the
specification are cited as "section 7.3"; the specification is at
opensheaf.org.
Names, owners and signatures
- Digests, encodings and signatures: SHA-256 and SHA-512, base32, base58btc, and Ed25519 verified as section 7.2 asks.
- Names, keys and sheaf: URIs: genesis records, names,
did:keyURIs, canonical JSON,sheaf:URIs. - Owners and their key logs: the computed first version, rotation, exposure, ending, fork records, copies met.
- Signatures and the statuses of versions: signature files, and signed, vouched for, contested, unchecked, not a version.
- Branches and their verdicts: the evidence of a branch point, confirmed, unchecked or inconsistent.
Reading archives
- Reading archives over HTTP: requests, limits, errors and what they mean (cross-origin requests above all), SHA-512.
- Untrusted names and storage layouts: identifiers, versions, logical paths, the two layouts, and addresses built safely under the storage root.
- Validating against the JSON Schemas: a validator for the keywords the schemas use, with formats as assertions.
- Document versions and history: the history, the current version, and the rules of section 4.2.
- An archive read over HTTP: the discovery document, inventories, pins, files, key logs, and lines with their statuses.
- Resolution: copies, pins and sheaf: URIs: copies found and checked, the statuses of pins, the latest signed version among the copies that agree, and a budget for walking collections.
Verifying
- The rules of an archive: findings, descriptions, member lists, what the indexes should hold.
- Verifying an archive in the browser: the whole
verification, in agreement with
osheaf verify, and what it does not check, and why.
The pages
- Building pages from untrusted data.
- Mathematics as plain text.
- Pieces of pages, and the summaries of objects.
- The page of an archive.
- The page of an object.
- The page of a collection.
- The page of the verification.
- The page of an owner.
- The application: the three ways of using it, the start, the pages, embedding and self-hosting.
- The stylesheet.
The tests
- The tests: fixture archives made with
osheaf, broken copies, and the comparison withosheaf verify. - The tests of names, keys and signatures, against appendix C of the specification and the edge cases of Ed25519.
- The tests across archives: resolution, the statuses of pins, branch points.
The literate tools, tangling and weaving, are described in their own literate program, opensheaf-literate.