Expand description
The file that keeps a headless srvβs browser sessions across a restart (sessions.bin, in the data root).
docs/specs/SPEC_WINDOWS_HEADLESS_AS_A_SERVICE_2026_11_20.md D.2.
What it holds: for each live session the SHA-256 of its cookie and of its per-tab token (the same digests the store keeps
in memory, never a cookie or a token), when it was confirmed and when it was last used, as wall-clock seconds. One-time
codes and pending sessions are never written. The file is written by a temp file and a rename, owner-only, when a session is
confirmed or ended and (at most every SAVE_EVERY) when one is used.
What it refuses: a file that cannot be trusted is ignored, every session in it is cleared, and the reason is logged once (never a digest). That is a file whose folder or own access list lets anyone but the owner, the system and the administrators open it, one that is truncated, has extra bytes, does not parse or fails its check value, one saved at a time after now (the clock has moved back, so the time that has passed is unknown), one with a time that cannot be (a session used before it was confirmed, or after the file was saved), and one made under a different sign-in key when the key is one the person provided. A key srv generated is new at every start, so a session cannot depend on it: the check value of such a file is a plain SHA-256, and of a file made under a provided key an HMAC under that key.
StructsΒ§
- Record π
- One saved session: the digests and the wall-clock seconds of its confirmation and last use.
EnumsΒ§
- KeyBinding π
- What the file is bound to: nothing (the key was generated at this start), or the key the person provided.
- Refused π
- Why the file was not used. A fixed text: it names no value from the file.
ConstantsΒ§
- FILE_
NAME π - The fileβs name in the data root.
- HEADER_
LEN π - MAGIC π
- MAX_
SESSIONS π - Most sessions the file holds or accepts.
- RECORD_
LEN π - SAVE_
EVERY π - A use of a session is written at most this often; the saved time of last use is then at most this stale, which makes a session older after a restart, never younger.
- TRAILER_
LEN π
FunctionsΒ§
- clear π
- Delete the file (a logout, or a refusal). Nothing is wrong if it is not there. When it cannot be deleted (a sharing violation, a scanner holding it) it is replaced by a file with no sessions; only when that fails too is the error returned, and the file, with whatever sessions it holds, is still there.
- decode π
- The sessions in
bytes, if it is a whole file made underbindingand saved at or beforenow_secs. - encode π
- The bytes of a file of
records, saved atsaved_secs. - load π
- Read the file:
Ok(None)when there is none, the sessions when it can be trusted. On any refusal the file is deleted, so a later start does not meet it again. - private_
enough π - Whether the file and its folder can be opened by nobody but the owner, the system and the administrators. A failure to find out is a refusal.
- save π
- Write the file: a temp file in the same folder (owner-only before it holds anything on unix, and with its list set on Windows) and a rename over the old one.
Type AliasesΒ§
- Digest32 π