Skip to main content

Module recipe

Module recipe 

Source
Expand description

Password recipes (R41): a template such as {prefix}-{list:food}-{random:12:base62} that makes an ordinary password.

A recipe is configuration, not a scheme. It runs once, at generation, and the result is stored like any other password, so redaction, history, exec, render and an older desktop keep working with no change. Nothing here reads the clock or the vault: the caller passes the date, the entry’s facts, the lists and a source of randomness, so a recipe with the same template and the same draws renders the same string.

The token list is data (data/recipe-tokens.json). Every id in it has an implementation in this file and every implementation has a descriptor; a test fails when either side is missing one.

Strength is counted honestly: only the random draws add bits. A lengthener adds length and no bits, so the figure never rises above what was drawn.

Structs§

Arg
One argument of a token: literal text, or $name (a fact or entry datum).
Ctx
What a recipe may read: the entry’s public facts, the person’s facts and lists, and the date.
Generated
The finished password and how it was made. Nothing in it but text is secret.
Options
Recipe-level settings, applied after the tokens render.
Part
One token’s share of a result, for the preview table.
PoolDraw
Draws from a pool filled by entropy::fill, so a chosen entropy source is honoured and an external device is read once per refill and not once per character.
Saved
A saved recipe.
SeqDraw
A fixed sequence for tests and goldens (xorshift64*). Never used for a real password.
SysDraw
The operating system’s generator.
Template
Token
{kind:arg:arg|transform:arg}, optionally marked droppable with ?N.

Enums§

Seg

Constants§

DEFAULT_FLOOR_BITS
The default floor under the random bits of a result.
RULE_KINDS
What an assignment rule matches on.
TOKEN_IDS
Tokens that produce a value.
TRANSFORM_IDS
Transforms and lengtheners, used after a |.

Traits§

Draw
A source of uniform draws. The recipe never asks for more than below.

Functions§

add_rule
Appends a rule. The recipe must exist.
analyse
The random bits a template would give, without drawing: the strength figure for the editor. Errors from missing facts surface here too, so the editor shows them while the person types.
builtin_lists
The built-in lists by name.
context
The context for generating a password for entry (or for no entry at all, when testing). now is YYYY-MM-DD, passed in so nothing here reads the clock.
custom_lists
Your own lists: (name, words, private).
estimate_bits
A rough strength for text the person typed: length times the size of the character pool it draws on. An estimate, labelled as one, never a promise.
facts
Your facts: (name, value, private).
generate
Makes a password from t. The random draws come from rng; everything else from ctx.
generated_by
The public record of how a password was made: the recipe name, the counter and the date. It holds no secret and no draw, so it is safe in every listing.
make
Parses template and generates in one call.
parse
Parses a template. Text outside braces is literal; {{ and }} are literal braces.
registry
The registry as JSON (descriptors for every token): what the settings forms are drawn from.
remove
Removes a recipe and every rule and default that named it. Returns whether it existed.
remove_fact
Removes a fact. Returns whether it existed.
remove_list
Removes a list of yours. Returns whether it existed.
remove_rule
Removes the rule at 1-based n. Returns whether it existed.
resolve
Which saved recipe applies to entry, and why: the entry’s own pick, the first matching rule, then the vault default; None means plain random, as before recipes existed.
rules
The assignment rules, in order: (kind, value, recipe).
save
Stores a recipe by name (replacing one of that name when replace). The template must parse.
save_list
Stores one of your lists. Words are trimmed and deduplicated; fewer than 2 is refused.
saved
The saved recipes of a vault.
set_fact
Sets a fact. Names are lower-case words so {var:pet} and $pet are never ambiguous.