rolloutDifferencesFrom method

List<String> rolloutDifferencesFrom(
  1. AtClientPreference other
)

Where other would change what a running client does — one line per differing axis, empty when the two are interchangeable.

Compared by value rather than identity, and only over the axes fixed at construction: the mutable seedNamespaceKeys and crypto are excluded.

Implementation

List<String> rolloutDifferencesFrom(AtClientPreference other) {
  final differences = <String>[];

  void compare(String axis, Object? asked, Object? running) {
    if (asked != running) {
      differences.add('$axis (asked $asked, running $running)');
    }
  }

  compare('posture.writesPqByDefault', other.posture.writesPqByDefault,
      posture.writesPqByDefault);
  compare('posture.configuresPqProviders',
      other.posture.configuresPqProviders, posture.configuresPqProviders);
  compare('posture.keyExchangeMode', other.posture.keyExchangeMode.name,
      posture.keyExchangeMode.name);
  compare('pqStartupGates', other.pqStartupGates, pqStartupGates);
  compare('authenticationKeyAlgorithm', other.authenticationKeyAlgorithm.name,
      authenticationKeyAlgorithm.name);
  compare('disallowLegacyEncryption', other.disallowLegacyEncryption,
      disallowLegacyEncryption);
  // NOTE: order is meaning in both lists — it picks the algorithm — so they
  // are compared as strings rather than as sets.
  compare('sealsToKeyAlgorithms', '${other.sealsToKeyAlgorithms}',
      '$sealsToKeyAlgorithms');
  compare('keyEstablishmentAlgorithms', '${other.keyEstablishmentAlgorithms}',
      '$keyEstablishmentAlgorithms');

  final asked = other.dataSigningKeyAlgorithms;
  final running = dataSigningKeyAlgorithms;
  if (asked.length != running.length || !asked.containsAll(running)) {
    // NOTE: rendered strongest-first because a Set iterates in insertion
    // order, so two equal sets would otherwise print differently.
    String spell(Set<SigningAlgoType> algorithms) =>
        '{${SigningAlgoType.strongestFirst.where(algorithms.contains).map((a) => a.name).join(', ')}}';
    differences.add('dataSigningKeyAlgorithms (asked ${spell(asked)}, '
        'running ${spell(running)})');
  }
  return differences;
}