Treatment scan
std/secret::scan
Inputs
⇥ data: Stream<byte>
Outputs
↦ completed: Block<void>
↦ error: Block<string>
↦ failed: Block<void>
↦ finished: Block<void>
↦ scanned: Stream<byte>
Searches the values revealed by the engine in data, cutting the data when one is found.
The bytes received through data are given through scanned, unless they hold a value
the engine revealed, as is, in base64, URL-encoded, or as bytes when it is not text, such
as before uploading files that would not be masked anymore once they left the engine.
The last bytes received are held until the next ones come, as they could start a value:
nothing of a value found is given.
Once data ends without any value found, the bytes held are given and completed is
emitted. When a value is found, scanned and data are closed, failed is emitted, and
error names the secret the value comes from, never the value.
finished is emitted in both cases.
⚠️ scanned ends in both cases: only completed tells that all the data was given, and
that it holds no revealed value.
Values revealed while the data goes through are searched from then on. Only the values revealed by this engine are known, not those revealed by distant ones.
graph LR
T("scan()")
B["… 🟦 🟦 🟦"] -->|data| T
T -->|scanned| O["… 🟦 🟦 🟦"]
T -->|completed| C["〈🟩〉"]
T -->|failed| F["〈🟥〉"]
style B fill:#ffffff,stroke:#ffffff
style O fill:#ffffff,stroke:#ffffff
style C fill:#ffffff,stroke:#ffffff
style F fill:#ffffff,stroke:#ffffff