putSecret method

Future<void> putSecret(
  1. Secret secret, {
  2. bool allowReservedName = false,
})

Stores secret, overwriting any existing (namespace, name) entry.

Names beginning __ are reserved for system use (e.g. a crypto provider's key material such as __rk.<epoch>.<kid>) and are rejected with ArgumentError unless allowReservedName is set — which only system-level callers should do. This keeps app secrets and system secrets collision-free within a namespace.

Implementation

Future<void> putSecret(Secret secret,
    {bool allowReservedName = false}) async {
  if (!allowReservedName && secret.name.startsWith('__')) {
    throw ArgumentError.value(secret.name, 'secret.name',
        'Secret names beginning "__" are reserved for system use');
  }
  _secrets[_key(secret.namespace, secret.name)] = secret;
  await persistence?.save(listSecrets());
}