IF Commons GitHub

logical/canonical

Written to: 2 requirements: 2 proved, 0 partly, 0 failing, 0 with no test recorded. 0004-grc-documents FR-003, 0004-grc-documents FR-004

The canonical form of a document and what is made from it: RFC 8785's JSON Canonicalization Scheme (members sorted by the UTF-16 code units of their names, numbers as ECMAScript writes them, no white space), the SHA-256 of it as a document's digest, and the version 5 UUID that gives a derived thing the same id every time.

import { canonicalize } from "./canonical.ts";
canonicalize({ b: 1, a: 2.0 }); // '{"a":2,"b":1}'

Source: commons/grc/src/logical/canonical.ts

3 of 10 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

logical.canonicalizefunctionno test imports it
function canonicalize(value: unknown): string

JSON's canonical form (RFC 8785); a value that JSON cannot hold (undefined members are dropped, as JSON drops them).

logical.digestOffunctionno test imports it
function digestOf(value: unknown): Promise<Sha256>

The digest of a value: the SHA-256 of its canonical form, the same on every runtime.

logical.grcNamespacefunctionno test imports it
function grcNamespace(): Promise<Uuid>

The namespace of GRC's derived ids: the version 5 UUID of the URL namespace and urn:grc.

logical.idOffunctionno test imports it
function idOf(parts: readonly string[]): Promise<string>

The URN (urn:uuid:...) of a derived id: the same parts give the same id.

logical.uuidOffunctionno test imports it
function uuidOf(parts: readonly string[]): Promise<string>

The bare UUID of a derived id (OSCAL writes it without urn:uuid:).

canonicalizefunction
function canonicalize(value: unknown): string

JSON's canonical form (RFC 8785); a value that JSON cannot hold (undefined members are dropped, as JSON drops them).

Imported by 58 tests of the run (57 passed, 0 failed): the library's results

digestOffunction
function digestOf(value: unknown): Promise<Sha256>

The digest of a value: the SHA-256 of its canonical form, the same on every runtime.

Imported by 13 tests of the run (12 passed, 0 failed): the library's results

grcNamespacefunctionno test imports it
function grcNamespace(): Promise<Uuid>

The namespace of GRC's derived ids: the version 5 UUID of the URL namespace and urn:grc.

idOffunction
function idOf(parts: readonly string[]): Promise<string>

The URN (urn:uuid:...) of a derived id: the same parts give the same id.

Imported by 13 tests of the run (12 passed, 0 failed): the library's results

uuidOffunctionno test imports it
function uuidOf(parts: readonly string[]): Promise<string>

The bare UUID of a derived id (OSCAL writes it without urn:uuid:).

Titles, headings, exports, tables, columns and requirements. Esc closes.