OpenSheaf Explorer

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 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

  1. Digests, encodings and signatures: SHA-256 and SHA-512, base32, base58btc, and Ed25519 verified as section 7.2 asks.
  2. Names, keys and sheaf: URIs: genesis records, names, did:key URIs, canonical JSON, sheaf: URIs.
  3. Owners and their key logs: the computed first version, rotation, exposure, ending, fork records, copies met.
  4. Signatures and the statuses of versions: signature files, and signed, vouched for, contested, unchecked, not a version.
  5. Branches and their verdicts: the evidence of a branch point, confirmed, unchecked or inconsistent.

Reading archives

  1. Reading archives over HTTP: requests, limits, errors and what they mean (cross-origin requests above all), SHA-512.
  2. Untrusted names and storage layouts: identifiers, versions, logical paths, the two layouts, and addresses built safely under the storage root.
  3. Validating against the JSON Schemas: a validator for the keywords the schemas use, with formats as assertions.
  4. Document versions and history: the history, the current version, and the rules of section 4.2.
  5. An archive read over HTTP: the discovery document, inventories, pins, files, key logs, and lines with their statuses.
  6. 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

  1. The rules of an archive: findings, descriptions, member lists, what the indexes should hold.
  2. Verifying an archive in the browser: the whole verification, in agreement with osheaf verify, and what it does not check, and why.

The pages

  1. Building pages from untrusted data.
  2. Mathematics as plain text.
  3. Pieces of pages, and the summaries of objects.
  4. The page of an archive.
  5. The page of an object.
  6. The page of a collection.
  7. The page of the verification.
  8. The page of an owner.
  9. The application: the three ways of using it, the start, the pages, embedding and self-hosting.
  10. The stylesheet.

The tests

  1. The tests: fixture archives made with osheaf, broken copies, and the comparison with osheaf verify.
  2. The tests of names, keys and signatures, against appendix C of the specification and the edge cases of Ed25519.
  3. 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.