IF Commons GitHub

logical/keys

Written to: 3 requirements: 3 proved, 0 partly, 0 failing, 0 with no test recorded. 0004-change-control-keys FR-001, 0004-change-control-keys FR-002, 0004-change-control-keys FR-003

Custody of the keys that sign a fleet's changes: what is known of this machine's keys and Git (facts), the checks made from them with a stable code and the one fix each, whether the recovery key was proved lately, and the text of the file that lists the signers. Nothing here reads a key or runs a program: the facts are given, and a passphrase is never seen (it is typed into OpenSSH and Git only).

import { recoveryOverdue } from "./keys.ts";
recoveryOverdue("2026-01-01", "2026-12-01"); // true

Source: commons/change-control/src/logical/keys.ts

9 of 24 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.RECOVERY_DAYSconstno test imports it
const RECOVERY_DAYS: 183

The days after which the recovery key is to be proved again.

logical.checkKeysfunctionno test imports it
function checkKeys(f: Facts, now: string): readonly Finding[]

Every check, in order, each with its code and its one fix. Signing works where the first six hold (OpenSSH, the daily key and its passphrase, Git signing with it, the identity, the daily key listed).

logical.opensshSignsconstno test imports it
const opensshSigns: (version: string | undefined) => boolean

Whether a version of OpenSSH can sign for Git (8.2 and after).

logical.opensshVersionfunctionno test imports it
function opensshVersion(text: string): string | undefined

The version of OpenSSH from the first line ssh -V prints (OpenSSH_9.6p1 ...), or nothing.

logical.recoveryOverduefunctionno test imports it
function recoveryOverdue(checkedAt: string | undefined, now: string, days?: number): boolean

Whether the recovery key was never proved or was proved more than days days before now (both days, YYYY-MM-DD, or instants).

logical.renderSignersfunctionno test imports it
function renderSigners(signers: readonly Signer[], header?: string): string

The text of the file that lists a fleet's signers, as a tenant keeps it (signers.ts): a header, and the signers by name, role and public key.

logical.replaceKeyfunctionno test imports it
function replaceKey(signers: readonly Signer[], name: string, key: string, day: string): readonly Signer[] | undefined

The signers with the key of one replaced: the old key stays in the list, named <name>-retired-<day> and retired on the day (its signatures count for changes dated up to then, so that what it signed still verifies), and the new key has the name and the role; nothing where there is no such signer.

logical.sameKeyconstno test imports it
const sameKey: (a: string, b: string) => boolean

The two key lines are the same key (the type and the key, not the comment).

logical.signingWorksfunctionno test imports it
function signingWorks(findings: readonly Finding[]): boolean

Whether signing works: the checks that stop a commit being made and accepted all hold.

logical.withSignerfunctionno test imports it
function withSigner(signers: readonly Signer[], signer: Signer): string | readonly Signer[]

The signers with one added, or the same where the key is already listed; a name is used once.

logical.Factstypeno test imports it
type Facts = { /** The version of OpenSSH, like `9.6`, or nothing where it is not there. */ readonly openssh: string… (740 characters)
type Facts = {
  /** The version of OpenSSH, like `9.6`, or nothing where it is not there. */
  readonly openssh: string | undefined;
  readonly daily: { readonly exists: boolean; readonly hasPassphrase: boolean; readonly inAgent: boolean };
  readonly git: { readonly signs: boolean; readonly formatSsh: boolean; readonly signingKeyIsDaily: boolean; readonly identity: boolean };
  readonly signers: { readonly dailyListed: boolean; readonly recoveryListed: boolean };
  /** The recovery key: its private file is on this machine (it should not be), and the day it was last proved (a day, `YYYY-MM-DD`). */
  readonly recovery: { readonly privateHere: boolean; readonly checkedAt: string | undefined };
  readonly hookInstalled: boolean;
};

What is known of the machine: OpenSSH, the daily key, Git's settings for the repository, the signers and the recovery key.

logical.Findingtypeno test imports it
type Finding = { readonly code: string; readonly ok: boolean; readonly says: string; readonly fix: string };

One check: whether it holds, its code, what is wrong, and the one thing to do.

RECOVERY_DAYSconstno test imports it
const RECOVERY_DAYS: 183

The days after which the recovery key is to be proved again.

checkKeysfunction
function checkKeys(f: Facts, now: string): readonly Finding[]

Every check, in order, each with its code and its one fix. Signing works where the first six hold (OpenSSH, the daily key and its passphrase, Git signing with it, the identity, the daily key listed).

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

opensshSignsconst
const opensshSigns: (version: string | undefined) => boolean

Whether a version of OpenSSH can sign for Git (8.2 and after).

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

opensshVersionfunction
function opensshVersion(text: string): string | undefined

The version of OpenSSH from the first line ssh -V prints (OpenSSH_9.6p1 ...), or nothing.

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

recoveryOverduefunction
function recoveryOverdue(checkedAt: string | undefined, now: string, days?: number): boolean

Whether the recovery key was never proved or was proved more than days days before now (both days, YYYY-MM-DD, or instants).

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

renderSignersfunction
function renderSigners(signers: readonly Signer[], header?: string): string

The text of the file that lists a fleet's signers, as a tenant keeps it (signers.ts): a header, and the signers by name, role and public key.

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

replaceKeyfunction
function replaceKey(signers: readonly Signer[], name: string, key: string, day: string): readonly Signer[] | undefined

The signers with the key of one replaced: the old key stays in the list, named <name>-retired-<day> and retired on the day (its signatures count for changes dated up to then, so that what it signed still verifies), and the new key has the name and the role; nothing where there is no such signer.

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

sameKeyconstno test imports it
const sameKey: (a: string, b: string) => boolean

The two key lines are the same key (the type and the key, not the comment).

signingWorksfunction
function signingWorks(findings: readonly Finding[]): boolean

Whether signing works: the checks that stop a commit being made and accepted all hold.

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

withSignerfunction
function withSigner(signers: readonly Signer[], signer: Signer): string | readonly Signer[]

The signers with one added, or the same where the key is already listed; a name is used once.

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

Factstype
type Facts = { /** The version of OpenSSH, like `9.6`, or nothing where it is not there. */ readonly openssh: string… (740 characters)
type Facts = {
  /** The version of OpenSSH, like `9.6`, or nothing where it is not there. */
  readonly openssh: string | undefined;
  readonly daily: { readonly exists: boolean; readonly hasPassphrase: boolean; readonly inAgent: boolean };
  readonly git: { readonly signs: boolean; readonly formatSsh: boolean; readonly signingKeyIsDaily: boolean; readonly identity: boolean };
  readonly signers: { readonly dailyListed: boolean; readonly recoveryListed: boolean };
  /** The recovery key: its private file is on this machine (it should not be), and the day it was last proved (a day, `YYYY-MM-DD`). */
  readonly recovery: { readonly privateHere: boolean; readonly checkedAt: string | undefined };
  readonly hookInstalled: boolean;
};

What is known of the machine: OpenSSH, the daily key, Git's settings for the repository, the signers and the recovery key.

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

Findingtypeno test imports it
type Finding = { readonly code: string; readonly ok: boolean; readonly says: string; readonly fix: string };

One check: whether it holds, its code, what is wrong, and the one thing to do.

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