tom_secrets_client library

The Dart client of the Tom Secrets Manager: reads secrets from the local secrets service over its client protocol.

final client = await TomSecretsClient.connect();
final value = await client.get('[env:prod]db.main', field: 'UserName');
print(value.text);
value.dispose();

Classes

TomSecretBinding
One binding <dimension>:<value> of a reference's qualifiers.
TomSecretEntry
The entry a value was read from.
TomSecretFile
What a getFile answers B: an attachment or a typed key as bytes.
TomSecretKeyTarget
A key: the value of an entry's tsm.key field (telegram.bot_token).
TomSecretPathTarget
A path: a store, the group path below its root group and the entry title, each segment unescaped.
TomSecretReference
A parsed reference. parse refuses a malformed one with a TomSecretsClientException of kind malformed whose reason is the rule of protocol.md 4.6 it broke; format gives the canonical form (4.5).
TomSecretRequest
One reference of a getMany.
TomSecretResult
One result of a getMany, in request order: a value or an error.
TomSecretsClient
A client of the Tom Secrets Manager's secrets service.
TomSecretsEndpoints
The runtime directory and its endpoint files.
TomSecretsFrame
One frame read from a connection.
TomSecretsFrameReader
Splits a byte stream into frames, checking every length against maxPayload before the payload is read and refusing a frame type that is neither JSON nor (with binaryAllowed) binary.
TomSecretsLocation
Where the service's endpoints are, by the rules of protocol.md 3.1.
TomSecretsLoginCandidate
A login entry match found for a page (protocol.md 5.5): never a value.
TomSecretsNoRuntimeDirectory
No runtime directory can be named (Windows without LOCALAPPDATA and USERPROFILE): the service is not_running.
TomSecretsProgress
A progress notice: passed to a call's onProgress.
TomSecretsWelcome
What the service said in welcome.
TomSecretTarget
What a reference names: a key, a path or a uuid reference.
TomSecretUuidTarget
A uuid reference: an entry of a store by its KDBX UUID (lower case).
TomSecretValue
A secret. Its toString never shows it, and dispose overwrites its buffer. A text the caller takes out is an immutable Dart string the library cannot overwrite: the caller handles it.
TomSecretVersion
The entry's last modification and the store file revision it was read from; a caller caching a value compares it to see a change.

Enums

TomSecretEncoding
How the service sent a value.
TomSecretsErrorKind
What went wrong: the protocol's error kinds plus notRunning.
TomSecretSource
Where a value came from: github when its store was fetched from GitHub in this refresh cycle, file when it was read from a file: vault on the local disk in this cycle, cache when the service serves its offline copy.
TomSecretsPending
Why a request waits (progress, 5.4).

Constants

tomSecretsClientFeatures → const List<String>
The features this library takes B (protocol.md 8): binary frames, getFile, match and propose.
tomSecretsClientVersion → const String
The library's version, sent in hello (kept equal to the pubspec's by a test).
tomSecretsDefaultField → const String
The field a reference without #field names.
tomSecretsFrameBinary → const int
Frame type of a binary chunk (B, 2.5).
tomSecretsFrameJson → const int
Frame type of a JSON payload.
tomSecretsMaxAnswerPayload → const int
The largest payload of a frame sent by the service.
tomSecretsMaxGetMany → const int
The most references one getMany carries.
tomSecretsMaxReferenceBytes → const int
The longest reference, in bytes of UTF-8 as sent.
tomSecretsMaxRequestPayload → const int
The largest payload of a frame sent to the service.
tomSecretsProtocol → const int
The protocol version this library speaks.

Functions

currentUid() → int?
The numeric id of the process's user (POSIX getuid); null on Windows.
discoverTomSecrets({required String operatingSystem, required Map<String, String> environment, int? uid()?}) → TomSecretsLocation
The location of the service for operatingSystem (linux, macos, windows; others are treated as linux), environment and the numeric user id uid (needed only for the /tmp/tsm-<uid> fallback).
readTomSecretsPortFile(String text) → int?
The port of a port file's text (decimal 1-65535, no sign or leading zero, at most one trailing LF or CR LF), or null when it is unreadable.
tomSecretsDecodePayload(List<int> payload) → Map<String, Object?>
The message of a JSON payload, or TomSecretsFrameException when it is malformed (2.2): empty, not UTF-8, not JSON, not an object, an object with a duplicate member name, or without a string op.
tomSecretsEncodeFrame(int type, List<int> payload) → Uint8List
A frame: the payload length (4 bytes big-endian), the type, the payload.
tomSecretsJsonFrame(Map<String, Object?> message) → Uint8List
The JSON frame of message.
tomSecretsJsonPayload(Map<String, Object?> message) → Uint8List
The compact UTF-8 JSON of message, as the vectors write it.

Typedefs

TomSecretsProgressCallback = void Function(TomSecretsProgress progress)
Receives the progress notices of a waiting request.

Exceptions / Errors

TomSecretsClientException
A call that failed. Never carries a value or a token.
TomSecretsFrameException
A frame or payload that breaks section 2; the connection is closed.