authScimApplicationSourceSnapshotId function

String authScimApplicationSourceSnapshotId(
  1. AuthScimApplicationProjectionScope scope,
  2. Iterable<AuthScimApplicationProjectionSnapshot> authoritative
)

Computes the canonical digest for a complete authoritative source snapshot.

Only stable scope/resource identifiers, source digests and versions, lifecycle state, and stable member identifiers are included. Email, username, credentials, auth-user IDs, and authorization state are not part of this boundary.

Implementation

String authScimApplicationSourceSnapshotId(
  AuthScimApplicationProjectionScope scope,
  Iterable<AuthScimApplicationProjectionSnapshot> authoritative,
) {
  final values = List<AuthScimApplicationProjectionSnapshot>.unmodifiable(
    authoritative,
  );
  _validateAuthoritative(scope, values);
  if (values.isEmpty) return authScimEmptyApplicationProjectionSnapshotId;
  final canonical = values.toList()
    ..sort((left, right) => _compareSubjects(left.subject, right.subject));
  return sha256
      .convert(
        utf8.encode(
          jsonEncode(<Object?>[
            for (final snapshot in canonical) _snapshotJson(snapshot),
          ]),
        ),
      )
      .toString();
}