diff options
| author | Harsh Shandilya <me@msfjarvis.dev> | 2022-06-09 13:51:29 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-09 13:51:29 +0530 |
| commit | 426fc924fba28ec898681ad7f7010456554f061e (patch) | |
| tree | 195eac25c605a89f4e239578d685928a64675ee0 /app/src/main/java/dev/msfjarvis/aps/util | |
| parent | f968b21bf665975e17ad9b03bcff652000e96ec4 (diff) | |
| download | HardenedPass-426fc924fba28ec898681ad7f7010456554f061e.tar.gz HardenedPass-426fc924fba28ec898681ad7f7010456554f061e.zip | |
Upgrade ktfmt (#1942)
* build-logic: upgrade ktfmt
* all: reformat
Diffstat (limited to 'app/src/main/java/dev/msfjarvis/aps/util')
6 files changed, 22 insertions, 12 deletions
diff --git a/app/src/main/java/dev/msfjarvis/aps/util/auth/BiometricAuthenticator.kt b/app/src/main/java/dev/msfjarvis/aps/util/auth/BiometricAuthenticator.kt index 50f11b5b..38ff812a 100644 --- a/app/src/main/java/dev/msfjarvis/aps/util/auth/BiometricAuthenticator.kt +++ b/app/src/main/java/dev/msfjarvis/aps/util/auth/BiometricAuthenticator.kt @@ -87,7 +87,8 @@ object BiometricAuthenticator { BiometricPrompt.ERROR_UNABLE_TO_PROCESS -> { Result.Retry } - // We cover all guaranteed values above, but [errorCode] is still an Int at the end of + // We cover all guaranteed values above, but [errorCode] is still an Int + // at the end of // the day so a // catch-all else will always be required. else -> { diff --git a/app/src/main/java/dev/msfjarvis/aps/util/git/sshj/OpenKeychainKeyProvider.kt b/app/src/main/java/dev/msfjarvis/aps/util/git/sshj/OpenKeychainKeyProvider.kt index 349e70e5..8436d1ce 100644 --- a/app/src/main/java/dev/msfjarvis/aps/util/git/sshj/OpenKeychainKeyProvider.kt +++ b/app/src/main/java/dev/msfjarvis/aps/util/git/sshj/OpenKeychainKeyProvider.kt @@ -145,7 +145,8 @@ class OpenKeychainKeyProvider private constructor(val activity: ContinuationCont } private suspend fun parseResult(request: Request, result: Intent): ApiResponse { - return when (result.getIntExtra( + return when ( + result.getIntExtra( SshAuthenticationApi.EXTRA_RESULT_CODE, SshAuthenticationApi.RESULT_CODE_ERROR ) @@ -196,8 +197,8 @@ class OpenKeychainKeyProvider private constructor(val activity: ContinuationCont privateKey = object : OpenKeychainPrivateKey { override suspend fun sign(challenge: ByteArray, hashAlgorithm: Int) = - when (val signingResponse = - executeApiRequest(SigningRequest(challenge, keyId, hashAlgorithm)) + when ( + val signingResponse = executeApiRequest(SigningRequest(challenge, keyId, hashAlgorithm)) ) { is ApiResponse.Success -> (signingResponse.response as SigningResponse).signature is ApiResponse.GeneralError -> throw signingResponse.exception diff --git a/app/src/main/java/dev/msfjarvis/aps/util/git/sshj/SshKey.kt b/app/src/main/java/dev/msfjarvis/aps/util/git/sshj/SshKey.kt index 67e063a4..ea96af53 100644 --- a/app/src/main/java/dev/msfjarvis/aps/util/git/sshj/SshKey.kt +++ b/app/src/main/java/dev/msfjarvis/aps/util/git/sshj/SshKey.kt @@ -209,7 +209,8 @@ object SshKey { // The file must have more than 2 lines, and the first and last line must have private key // markers. - if (lines.size < 2 || + if ( + lines.size < 2 || !Regex("BEGIN .* PRIVATE KEY").containsMatchIn(lines.first()) || !Regex("END .* PRIVATE KEY").containsMatchIn(lines.last()) ) @@ -349,9 +350,12 @@ object SshKey { override fun getPrivate(): PrivateKey = runCatching { - // The current MasterKey API does not allow getting a reference to an existing one - // without specifying the KeySpec for a new one. However, the value for passed here - // for `requireAuthentication` is not used as the key already exists at this point. + // The current MasterKey API does not allow getting a reference to an existing + // one + // without specifying the KeySpec for a new one. However, the value for passed + // here + // for `requireAuthentication` is not used as the key already exists at this + // point. val encryptedPrivateKeyFile = runBlocking { getOrCreateWrappedPrivateKeyFile(false) } val rawPrivateKey = encryptedPrivateKeyFile.openFileInput().use { it.readBytes() } EdDSAPrivateKey( diff --git a/app/src/main/java/dev/msfjarvis/aps/util/settings/GitSettings.kt b/app/src/main/java/dev/msfjarvis/aps/util/settings/GitSettings.kt index 8cbf84d9..4f5187c4 100644 --- a/app/src/main/java/dev/msfjarvis/aps/util/settings/GitSettings.kt +++ b/app/src/main/java/dev/msfjarvis/aps/util/settings/GitSettings.kt @@ -150,7 +150,8 @@ constructor( in listOf("ssh", null) -> Protocol.Ssh else -> return UpdateConnectionSettingsResult.FailedToParseUrl } - if ((newAuthMode != AuthMode.None && newProtocol != Protocol.Https) && + if ( + (newAuthMode != AuthMode.None && newProtocol != Protocol.Https) && parsedUrl.user.isNullOrBlank() ) return UpdateConnectionSettingsResult.MissingUsername(newProtocol) diff --git a/app/src/main/java/dev/msfjarvis/aps/util/settings/Migrations.kt b/app/src/main/java/dev/msfjarvis/aps/util/settings/Migrations.kt index b90856b1..b96e538f 100644 --- a/app/src/main/java/dev/msfjarvis/aps/util/settings/Migrations.kt +++ b/app/src/main/java/dev/msfjarvis/aps/util/settings/Migrations.kt @@ -77,7 +77,8 @@ private fun migrateToGitUrlBasedConfig(sharedPrefs: SharedPreferences, gitSettin remove(PreferenceKeys.GIT_REMOTE_USERNAME) remove(PreferenceKeys.GIT_REMOTE_PROTOCOL) } - if (url == null || + if ( + url == null || gitSettings.updateConnectionSettingsIfValid( newAuthMode = gitSettings.authMode, newUrl = url, @@ -99,7 +100,8 @@ private fun migrateToHideAll(sharedPrefs: SharedPreferences) { private fun migrateToSshKey(filesDirPath: String, sharedPrefs: SharedPreferences) { val privateKeyFile = File(filesDirPath, ".ssh_key") - if (sharedPrefs.contains(PreferenceKeys.USE_GENERATED_KEY) && + if ( + sharedPrefs.contains(PreferenceKeys.USE_GENERATED_KEY) && !SshKey.exists && privateKeyFile.exists() ) { diff --git a/app/src/main/java/dev/msfjarvis/aps/util/totp/UriTotpFinder.kt b/app/src/main/java/dev/msfjarvis/aps/util/totp/UriTotpFinder.kt index ecf5f1ca..9c4dc4f4 100644 --- a/app/src/main/java/dev/msfjarvis/aps/util/totp/UriTotpFinder.kt +++ b/app/src/main/java/dev/msfjarvis/aps/util/totp/UriTotpFinder.kt @@ -42,7 +42,8 @@ class UriTotpFinder @Inject constructor() : TotpFinder { private fun getQueryParameter(content: String, parameterName: String): String? { content.split("\n".toRegex()).forEach { line -> val uri = Uri.parse(line) - if (line.startsWith(TotpFinder.TOTP_FIELDS[0]) && uri.getQueryParameter(parameterName) != null + if ( + line.startsWith(TotpFinder.TOTP_FIELDS[0]) && uri.getQueryParameter(parameterName) != null ) { return uri.getQueryParameter(parameterName) } |
