httk.workflow.configuration¶
Manage XDG configuration and identity for workflow commands.
The per-user configuration and data directory functions are provided by
httk.core.userdirs and re-exported here for workflow callers.
Attributes¶
Classes¶
Describe one member the user configuration is allowed to carry. |
|
Report what checking one document's optional identity signature established. |
Functions¶
Return the configuration keys |
|
Adopt whatever an earlier release left in the data home, once. |
|
Return where this user's remote definitions live. |
|
Return where this user's identity keys live. |
|
Return the path of this user's configuration file. |
|
Read the user configuration, returning an empty mapping if absent. |
|
Return the configured names by which this machine is addressed. |
|
|
Write a versioned user configuration. |
|
Set one registered configuration key and return the written path. |
|
Remove one registered configuration key and return the written path. |
|
Create or update the user identity and ensure a signing key exists. |
Return the paths of the local identity seed and public key. |
|
Create the user's standard Ed25519 identity key if it is absent. |
|
Return the local identity seed, or |
|
Return the recorded local identity public key, or |
|
|
Return the domain-separated digest one identity signature covers. |
|
Return document with a detached identity signature, when one is possible. |
|
Check the optional identity signature of document. |
|
Import safe metadata and public identity from a legacy |
Module Contents¶
- class httk.workflow.configuration.ConfigKey[source]¶
Describe one member the user configuration is allowed to carry.
- Parameters:
name – Configuration member name.
description – Human-readable explanation shown to operators.
settable – Whether
config setmay change the member.
- httk.workflow.configuration.CONFIG_KEYS: collections.abc.Mapping[str, ConfigKey][source]¶
- httk.workflow.configuration.settable_config_keys()[source]¶
Return the configuration keys
config setaccepts, in order.
- httk.workflow.configuration.adopt_legacy_data_home()[source]¶
Adopt whatever an earlier release left in the data home, once.
- Returns:
None.- Return type:
None
- httk.workflow.configuration.remotes_home()[source]¶
Return where this user’s remote definitions live.
- Returns:
Per-user remote definition directory.
- Return type:
- httk.workflow.configuration.keys_home()[source]¶
Return where this user’s identity keys live.
- Returns:
Per-user identity key directory.
- Return type:
- httk.workflow.configuration.config_path()[source]¶
Return the path of this user’s configuration file.
- Returns:
User configuration path.
- Return type:
- httk.workflow.configuration.read_config()[source]¶
Read the user configuration, returning an empty mapping if absent.
A document of an unrecognized format is refused by name rather than read as if its members meant what this implementation means by them. A document with no version at all predates versioning and is accepted as legacy, because that is what every configuration written before this check looks like.
- Returns:
Configuration members, or an empty mapping when no file exists.
- Raises:
ValueError – If the file is not a supported configuration document.
- Return type:
- httk.workflow.configuration.machine_names()[source]¶
Return the configured names by which this machine is addressed.
- Returns:
Names configured for this machine.
- Raises:
ValueError – If
machine_namesis not a valid comma-separated value.- Return type:
- httk.workflow.configuration.write_config(values)[source]¶
Write a versioned user configuration.
- Parameters:
values (collections.abc.Mapping[str, object]) – Configuration members to write.
- Returns:
Path of the written configuration file.
- Return type:
- httk.workflow.configuration.set_config_key(key, value)[source]¶
Set one registered configuration key and return the written path.
- Parameters:
- Returns:
Path of the written configuration file.
- Raises:
ValueError – If the key is not settable or its value is invalid.
- Return type:
- httk.workflow.configuration.unset_config_key(key)[source]¶
Remove one registered configuration key and return the written path.
- Parameters:
key (str) – Settable configuration member name.
- Returns:
Path of the written configuration file.
- Raises:
ValueError – If the key is not settable or is not configured.
- Return type:
- httk.workflow.configuration.initialize_config(*, name, email)[source]¶
Create or update the user identity and ensure a signing key exists.
- httk.workflow.configuration.identity_key_paths()[source]¶
Return the paths of the local identity seed and public key.
- Returns:
Seed path followed by public-key path.
- Return type:
- httk.workflow.configuration.ensure_identity_key()[source]¶
Create the user’s standard Ed25519 identity key if it is absent.
- Returns:
Seed path followed by public-key path.
- Raises:
ValueError – If an existing seed is not a standard Ed25519 seed.
- Return type:
- httk.workflow.configuration.identity_seed()[source]¶
Return the local identity seed, or
Nonewhen no key was created.Nothing here creates a key. An installation that never ran
config initsimply has no identity, and every caller treats that as unsigned rather than as an error, which is what keeps a mixed deployment working.- Returns:
The local seed, or no value when no valid key exists.
- Return type:
bytes | None
- httk.workflow.configuration.identity_public_key()[source]¶
Return the recorded local identity public key, or
None.- Returns:
Encoded public key, or
Nonewhen no identity exists.- Return type:
str | None
- httk.workflow.configuration.signature_digest(document)[source]¶
Return the domain-separated digest one identity signature covers.
The digest covers the whole document except the signature itself, in the same canonical JSON every other httk document is hashed as, so the signing key and the signed members travel together and neither can be swapped.
- Parameters:
document (collections.abc.Mapping[str, object]) – Document whose detached signature is being calculated.
- Returns:
Domain-separated digest of the unsigned document.
- Return type:
- httk.workflow.configuration.sign_document(document)[source]¶
Return document with a detached identity signature, when one is possible.
Signing is optional by construction: a caller with no identity key returns the document unchanged, and a verifier accepts an unsigned document. The signature is attribution — it says which identity published this — and never authorization: nothing is permitted because a document is signed.
- class httk.workflow.configuration.DocumentSignature[source]¶
Report what checking one document’s optional identity signature established.
- Parameters:
present – Whether the document carried a signature block.
valid – Whether the carried signature verified.
operator_key – Encoded key from the signature, when present.
reason – Explanation when the signature is absent or invalid.
- httk.workflow.configuration.verify_document(document)[source]¶
Check the optional identity signature of document.
An absent signature is reported as absent rather than as a failure, so a document published by an installation without an identity key stays usable. A signature that is present and does not verify is a failure: it is either damaged or forged, and neither is something to act on.
- Parameters:
document (collections.abc.Mapping[str, object]) – Document whose optional signature is checked.
- Returns:
Signature presence and verification result.
- Return type:
- httk.workflow.configuration.import_v1_configuration(source=None)[source]¶
Import safe metadata and public identity from a legacy
~/.httktree.Legacy 64-byte private material is deliberately left untouched.
- Parameters:
source (str | os.PathLike[str] | None) – Legacy configuration root, or the default legacy home.
- Returns:
Imported configuration members.
- Raises:
FileNotFoundError – If the legacy configuration file is absent.
- Return type: