IF Commons GitHub

physical/store

Written to: 2 requirements: 2 proved, 0 partly, 0 failing, 0 with no test recorded. 0006-grc-evidence FR-001, 0006-grc-evidence FR-003

The evidence store port (0006-grc-evidence): content-addressed storage of what was observed, with the grc.evidence document that describes each object. The registry holds stores by id; the stores are units of their own. Retention is decided by pure functions here, and a store never deletes by itself.

Source: commons/grc/src/physical/store.ts

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

physical.EvidenceMetatypeno test imports it
type EvidenceMeta = { readonly subject: string; readonly type: string; readonly mediaType: string; readonly observedAt: string; readonly producer?: string };

What a store is told about bytes it is given.

physical.StoreProblemtypeno test imports it
type StoreProblem = { readonly kind: "missing" | "tampered" | "failed"; readonly digest: string; readonly message: string };

Why a store did not do what it was asked.

physical.EvidenceFiltertypeno test imports it
type EvidenceFilter = { readonly subject?: string; readonly type?: string };

What list is asked for.

physical.EvidenceStoretypeno test imports it
type EvidenceStore = { readonly id: string; /** Keeps the bytes under their SHA-256 and gives the evidence that desc… (590 characters)
type EvidenceStore = {
  readonly id: string;
  /** Keeps the bytes under their SHA-256 and gives the evidence that describes them; the same bytes twice are one object. */
  put(bytes: Uint8Array, meta: EvidenceMeta): Promise<Result<Evidence, StoreProblem>>;
  /** The bytes of a digest, verified: a missing digest, or bytes that do not match it, is a problem. */
  get(digest: string): Promise<Result<Uint8Array, StoreProblem>>;
  has(digest: string): Promise<boolean>;
  /** The evidence, in the order of their digests. */
  list(filter?: EvidenceFilter): Promise<readonly Evidence[]>;
};

A store of evidence.

physical.Storestypeno test imports it
type Stores = Registry<EvidenceStore>;

A registry of stores.

physical.createStoresfunctionno test imports it
function createStores(): Stores

A registry of stores, empty.

physical.evidenceOffunctionno test imports it
function evidenceOf(bytes: Uint8Array<ArrayBufferLike>, meta: EvidenceMeta, store: string): Promise<Document & { readonly subject: string; readonly type: string; readonly digest: string; readonly mediaType: string; readonly size: number; readonly observedAt: string; } & { readonly store?: string | undefined; readonly producer?: string | undefined; }>

The evidence document of bytes.

physical.verifiedfunctionno test imports it
function verified(digest: string, bytes: Uint8Array<ArrayBufferLike>): Promise<Result<Uint8Array<ArrayBufferLike>, StoreProblem>>

Bytes read back, held to their digest.

physical.retainedfunctionno test imports it
function retained(e: Document & { readonly subject: string; readonly type: string; readonly digest: string; readonly med… (598 characters)
function retained(e: Document & { readonly subject: string; readonly type: string; readonly digest: string; readonly mediaType: string; readonly size: number; readonly observedAt: string; } & { readonly store?: string | undefined; readonly producer?: string | undefined; }, policy: Document & { readonly counts: readonly ObjectOf<{ kinds: Decoder<readonly string[]>; maxAge: Decoder<string>; }, { producers: Decoder<readonly string[]>; }>[]; readonly retention: string; readonly attesters: readonly string[]; readonly custody: "file" | "hardware" | "managed" | "none"; } & {}, now: string): boolean

Whether an item is still to be kept at now: its retention (from the evidence policy) has not passed since it was observed.

physical.expiredfunctionno test imports it
function expired(items: readonly (Document & { readonly subject: string; readonly type: string; readonly digest: string;… (871 characters)
function expired(items: readonly (Document & { readonly subject: string; readonly type: string; readonly digest: string; readonly mediaType: string; readonly size: number; readonly observedAt: string; } & { readonly store?: string | undefined; readonly producer?: string | undefined; })[], policy: Document & { readonly counts: readonly ObjectOf<{ kinds: Decoder<readonly string[]>; maxAge: Decoder<string>; }, { producers: Decoder<readonly string[]>; }>[]; readonly retention: string; readonly attesters: readonly string[]; readonly custody: "file" | "hardware" | "managed" | "none"; } & {}, now: string): readonly (Document & { readonly subject: string; readonly type: string; readonly digest: string; readonly mediaType: string; readonly size: number; readonly observedAt: string; } & { readonly store?: string | undefined; readonly producer?: string | undefined; })[]

The items whose retention has passed: the caller decides whether to delete them.

EvidenceMetatypeno test imports it
type EvidenceMeta = { readonly subject: string; readonly type: string; readonly mediaType: string; readonly observedAt: string; readonly producer?: string };

What a store is told about bytes it is given.

StoreProblemtypeno test imports it
type StoreProblem = { readonly kind: "missing" | "tampered" | "failed"; readonly digest: string; readonly message: string };

Why a store did not do what it was asked.

EvidenceFiltertypeno test imports it
type EvidenceFilter = { readonly subject?: string; readonly type?: string };

What list is asked for.

EvidenceStoretype
type EvidenceStore = { readonly id: string; /** Keeps the bytes under their SHA-256 and gives the evidence that desc… (590 characters)
type EvidenceStore = {
  readonly id: string;
  /** Keeps the bytes under their SHA-256 and gives the evidence that describes them; the same bytes twice are one object. */
  put(bytes: Uint8Array, meta: EvidenceMeta): Promise<Result<Evidence, StoreProblem>>;
  /** The bytes of a digest, verified: a missing digest, or bytes that do not match it, is a problem. */
  get(digest: string): Promise<Result<Uint8Array, StoreProblem>>;
  has(digest: string): Promise<boolean>;
  /** The evidence, in the order of their digests. */
  list(filter?: EvidenceFilter): Promise<readonly Evidence[]>;
};

A store of evidence.

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

Storestypeno test imports it
type Stores = Registry<EvidenceStore>;

A registry of stores.

createStoresfunction
function createStores(): Stores

A registry of stores, empty.

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

evidenceOffunction
function evidenceOf(bytes: Uint8Array<ArrayBufferLike>, meta: EvidenceMeta, store: string): Promise<Document & { readonly subject: string; readonly type: string; readonly digest: string; readonly mediaType: string; readonly size: number; readonly observedAt: string; } & { readonly store?: string | undefined; readonly producer?: string | undefined; }>

The evidence document of bytes.

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

verifiedfunctionno test imports it
function verified(digest: string, bytes: Uint8Array<ArrayBufferLike>): Promise<Result<Uint8Array<ArrayBufferLike>, StoreProblem>>

Bytes read back, held to their digest.

retainedfunction
function retained(e: Document & { readonly subject: string; readonly type: string; readonly digest: string; readonly med… (598 characters)
function retained(e: Document & { readonly subject: string; readonly type: string; readonly digest: string; readonly mediaType: string; readonly size: number; readonly observedAt: string; } & { readonly store?: string | undefined; readonly producer?: string | undefined; }, policy: Document & { readonly counts: readonly ObjectOf<{ kinds: Decoder<readonly string[]>; maxAge: Decoder<string>; }, { producers: Decoder<readonly string[]>; }>[]; readonly retention: string; readonly attesters: readonly string[]; readonly custody: "file" | "hardware" | "managed" | "none"; } & {}, now: string): boolean

Whether an item is still to be kept at now: its retention (from the evidence policy) has not passed since it was observed.

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

expiredfunction
function expired(items: readonly (Document & { readonly subject: string; readonly type: string; readonly digest: string;… (871 characters)
function expired(items: readonly (Document & { readonly subject: string; readonly type: string; readonly digest: string; readonly mediaType: string; readonly size: number; readonly observedAt: string; } & { readonly store?: string | undefined; readonly producer?: string | undefined; })[], policy: Document & { readonly counts: readonly ObjectOf<{ kinds: Decoder<readonly string[]>; maxAge: Decoder<string>; }, { producers: Decoder<readonly string[]>; }>[]; readonly retention: string; readonly attesters: readonly string[]; readonly custody: "file" | "hardware" | "managed" | "none"; } & {}, now: string): readonly (Document & { readonly subject: string; readonly type: string; readonly digest: string; readonly mediaType: string; readonly size: number; readonly observedAt: string; } & { readonly store?: string | undefined; readonly producer?: string | undefined; })[]

The items whose retention has passed: the caller decides whether to delete them.

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

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