dvKeychainRefusal function

DVAppKeyStoreUnavailable dvKeychainRefusal(
  1. int status,
  2. String operation
)

The refusal for a Keychain operation that answered status.

Pure, so the wording for each status is tested off a Mac. The statuses named are the ones a running application meets: a device that has not been unlocked since it booted (the item is available after first unlock), a process with no keychain entitlement, and a machine with no keychain.

Implementation

DVAppKeyStoreUnavailable dvKeychainRefusal(int status, String operation) {
  final String reason = switch (status) {
    _errSecInteractionNotAllowed =>
      'the device has not been unlocked since it started, and the key is '
          'kept for after first unlock; $operation was refused',
    _errSecMissingEntitlement =>
      'this process has no keychain entitlement, so $operation was refused; '
          'a signed application has one, an unsigned test host may not',
    _errSecNotAvailable =>
      'there is no keychain available to this process; $operation was refused',
    _errSecAuthFailed =>
      'the keychain is locked or refused the credentials; $operation was refused',
    _ => '$operation failed with OSStatus $status',
  };
  return DVAppKeyStoreUnavailable('the Keychain', reason, status: status);
}