Skip to main content

tom_secrets_core 0.2.0 copy "tom_secrets_core: ^0.2.0" to clipboard
tom_secrets_core: ^0.2.0 copied to clipboard

The core of the Tom Secrets Manager: secret stores over KDBX files, overlays, dimensions and the resolution of secret references, the GitHub vault cycle and the outer encryption.

example/tom_secrets_core_example.dart

// Copyright (c) 2026 Peter Nicolai Alexis Kyaw
// SPDX-License-Identifier: BSD-3-Clause

// Builds a demo vault in memory (demo data under a demo key) and resolves a
// key on two machines: the shared entry, and a host's overlay.

import 'package:tom_secrets_core/tom_secrets_core.dart';

void main() {
  final file = KdbxFormat().create(
    Credentials(ProtectedValue.fromString('demo-key')),
    'demo',
  );
  final root = file.body.rootGroup;
  void add(List<String> groups, String title, String password) {
    var group = root;
    for (final name in groups) {
      group =
          group.groups.where((g) => g.name.get() == name).firstOrNull ??
          file.createGroup(parent: group, name: name);
    }
    final entry = KdbxEntry.create(file, group);
    group.addEntry(entry);
    entry
      ..label = title
      ..setString(KdbxKeyCommon.PASSWORD, ProtectedValue.fromString(password))
      ..setString(TomSecretsEntryFields.key, PlainValue('telegram.bot_token'));
  }

  add(['Telegram'], 'Bot', 'demo-shared-token');
  add(['@host:bomber', 'Telegram'], 'Bot', 'demo-bomber-token');
  final store = TomSecretsStore.fromFile(file, name: 'fleet');

  for (final host in ['mbp', 'bomber']) {
    final resolver = TomSecretsResolver(
      stores: [store],
      config: TomSecretsConfig.builtIn(),
      machine: TomSecretsMachine(host: host, platform: 'linux'),
    );
    final resolution = resolver.resolve('telegram.bot_token');
    print(
      '$host: ${resolution.entry.store}/${resolution.entry.pathText} '
      'bound ${resolution.bound} -> ${resolution.value.text}',
    );
    resolution.value.dispose();
  }
}
0
likes
0
points
297
downloads

Publisher

unverified uploader

Weekly Downloads

The core of the Tom Secrets Manager: secret stores over KDBX files, overlays, dimensions and the resolution of secret references, the GitHub vault cycle and the outer encryption.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

archive, crypto, cryptography, http, pointycastle, tom_core_storage, tom_core_sync, tom_crypto, tom_git, tom_github_api, tom_kdbx_store, tom_pqc, tom_secrets_client, yaml

More

Packages that depend on tom_secrets_core