Skip to content

Commit

Permalink
Merge branch 'develop' into 'master'
Browse files Browse the repository at this point in the history
Develop

See merge request papers/airgap/airgap-vault!403
  • Loading branch information
godenzim committed Feb 14, 2023
2 parents e6ae6f2 + 2d105ee commit 3dbc816
Show file tree
Hide file tree
Showing 10 changed files with 140 additions and 94 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ android {
kotlinOptions {
jvmTarget = '11'
}
lintOptions {
lint {
abortOnError false
}
}
Expand Down Expand Up @@ -72,7 +72,7 @@ dependencies {
def fragmentVersion = "1.4.0"
implementation("androidx.fragment:fragment-ktx:$fragmentVersion")

def biometricVersion = "1.2.0-alpha04"
def biometricVersion = "1.2.0-alpha05"
implementation("androidx.biometric:biometric:$biometricVersion")

def coroutinesVersion = "1.6.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ import androidx.fragment.app.Fragment
import it.airgap.vault.R
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.Deferred
import java.util.concurrent.atomic.AtomicInteger

class AuthPromptFragment : Fragment(R.layout.fragment_authenticator) {

private val _resultDeferred: CompletableDeferred<Boolean> = CompletableDeferred()
val resultDeferred: Deferred<Boolean>
get() = _resultDeferred

private val attempts: AtomicInteger = AtomicInteger(0)

private var _biometricPromptInfo: BiometricPrompt.PromptInfo? = null
private val biometricPromptInfo: BiometricPrompt.PromptInfo
get() = _biometricPromptInfo ?: BiometricPrompt.PromptInfo.Builder().apply {
Expand All @@ -37,17 +40,21 @@ class AuthPromptFragment : Fragment(R.layout.fragment_authenticator) {
BiometricPrompt(this, executor, object : BiometricPrompt.AuthenticationCallback() {
override fun onAuthenticationError(errorCode: Int, errString: CharSequence) {
super.onAuthenticationError(errorCode, errString)
attempts.set(0)
_resultDeferred.complete(false)
}

override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) {
super.onAuthenticationSucceeded(result)
attempts.set(0)
_resultDeferred.complete(true)
}

override fun onAuthenticationFailed() {
super.onAuthenticationFailed()
_resultDeferred.complete(false)
if (attempts.incrementAndGet() >= MAX_AUTH_TRIES) {
_resultDeferred.complete(false)
}
}
})
}.also { _biometricPrompt = it }
Expand All @@ -64,4 +71,8 @@ class AuthPromptFragment : Fragment(R.layout.fragment_authenticator) {

super.onDestroyView()
}

companion object {
private const val MAX_AUTH_TRIES = 3
}
}
8 changes: 8 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ allprojects {
mavenCentral()
maven { url 'https://jitpack.io' }
}
afterEvaluate {
if (getPlugins().hasPlugin('android') ||
getPlugins().hasPlugin('android-library')) {
configure(android.lint) {
abortOnError false
}
}
}
}

task clean(type: Delete) {
Expand Down
4 changes: 2 additions & 2 deletions android/variables.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ext {
minSdkVersion = 22
compileSdkVersion = 32
targetSdkVersion = 32
compileSdkVersion = 33
targetSdkVersion = 33
androidxActivityVersion = '1.4.0'
androidxAppCompatVersion = '1.4.2'
androidxCoordinatorLayoutVersion = '1.2.0'
Expand Down
28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,23 @@
"apply-diagnostic-modules": "node apply-diagnostic-modules.js"
},
"dependencies": {
"@airgap/aeternity": "0.13.9",
"@airgap/aeternity": "0.13.10",
"@airgap/angular-core": "0.0.34",
"@airgap/angular-ngrx": "0.0.34",
"@airgap/astar": "0.13.9",
"@airgap/bitcoin": "0.13.9",
"@airgap/coinlib-core": "0.13.9",
"@airgap/cosmos": "0.13.9",
"@airgap/ethereum": "0.13.9",
"@airgap/groestlcoin": "0.13.9",
"@airgap/icp": "0.13.9",
"@airgap/module-kit": "0.13.9",
"@airgap/moonbeam": "0.13.9",
"@airgap/polkadot": "0.13.9",
"@airgap/astar": "0.13.10",
"@airgap/bitcoin": "0.13.10",
"@airgap/coinlib-core": "0.13.10",
"@airgap/cosmos": "0.13.10",
"@airgap/ethereum": "0.13.10",
"@airgap/groestlcoin": "0.13.10",
"@airgap/icp": "0.13.10",
"@airgap/module-kit": "0.13.10",
"@airgap/moonbeam": "0.13.10",
"@airgap/polkadot": "0.13.10",
"@airgap/sapling-wasm": "0.0.7",
"@airgap/serializer": "0.13.9",
"@airgap/substrate": "0.13.9",
"@airgap/tezos": "0.13.9",
"@airgap/serializer": "0.13.10",
"@airgap/substrate": "0.13.10",
"@airgap/tezos": "0.13.10",
"@angular/common": "13.2.5",
"@angular/core": "13.2.5",
"@angular/forms": "13.2.5",
Expand Down
2 changes: 1 addition & 1 deletion src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export class AppComponent implements AfterViewInit {
const protocol: string = data.url.substr(DEEPLINK_VAULT_ADD_ACCOUNT.length)
if (protocol.length > 0) {
this.navigationService
.routeWithState('account-add', { protocol })
.routeWithState('account-add', { protocol, secret: secrets[0] })
.catch(handleErrorLocal(ErrorCategory.IONIC_NAVIGATION))
} else {
this.navigationService.route('account-add').catch(handleErrorLocal(ErrorCategory.IONIC_NAVIGATION))
Expand Down
22 changes: 8 additions & 14 deletions src/app/pages/account-add/account-add.page.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component } from '@angular/core'
import { ModalController, AlertController } from '@ionic/angular'
import { ICoinProtocol, MainProtocolSymbols, ProtocolSymbols } from '@airgap/coinlib-core'
import { ICoinProtocol, ProtocolSymbols } from '@airgap/coinlib-core'

import { ErrorCategory, handleErrorLocal } from '../../services/error-handler/error-handler.service'
import { NavigationService } from '../../services/navigation/navigation.service'
Expand Down Expand Up @@ -62,9 +62,7 @@ export class AccountAddPage {
const state = this.navigationService.getState()
this.secret = state.secret
this.protocolService.getActiveProtocols().then(async (protocols: ICoinProtocol[]) => {
const navigationIdentifier: ProtocolSymbols | undefined = (this.navigationService.getState().protocol)
? await this.navigationService.getState().protocol.getIdentifier()
: undefined
const navigationIdentifier: ProtocolSymbols | undefined = state.protocol

this.protocolList = await Promise.all(protocols.map(async (protocol) => {
const [symbol, identifier, name, supportsHD] = await Promise.all([
Expand All @@ -73,17 +71,13 @@ export class AccountAddPage {
protocol.getName(),
protocol.getSupportsHD()
])
const isChecked = navigationIdentifier === identifier

const isChecked =
identifier === MainProtocolSymbols.BTC_SEGWIT ||
identifier === MainProtocolSymbols.ETH ||
navigationIdentifier === identifier

return {
protocol,
isHDWallet: supportsHD,
customDerivationPath: undefined,
isChecked: isChecked,
return {
protocol,
isHDWallet: supportsHD,
customDerivationPath: undefined,
isChecked: isChecked,
details: { symbol, identifier, name }
}
}))
Expand Down
33 changes: 30 additions & 3 deletions src/app/pages/secret-add/secret-add.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { MnemonicSecret } from '../../models/secret'
import { ErrorCategory, handleErrorLocal } from '../../services/error-handler/error-handler.service'
import { NavigationService } from '../../services/navigation/navigation.service'
import { SecretsService } from '../../services/secrets/secrets.service'
import { UiEventService } from '@airgap/angular-core'

@Component({
selector: 'airgap-secret-add',
Expand All @@ -32,7 +33,8 @@ export class SecretAddPage {
private readonly navigationService: NavigationService,
private readonly platform: Platform,
private readonly lifehashService: LifehashService,
private readonly storageService: VaultStorageService
private readonly storageService: VaultStorageService,
private readonly uiEventService: UiEventService
) {
if (this.navigationService.getState()) {
this.isGenerating = this.navigationService.getState().isGenerating
Expand All @@ -51,8 +53,11 @@ export class SecretAddPage {
} catch (error) {
handleErrorLocal(ErrorCategory.SECURE_STORAGE)(error)

// TODO: Show error
this.navigationService.routeToSecretsTab()
if (error.message !== 'Already added secret' /* a workaround to avoid prompting 2 alerts */) {
await this.showErrorAlert()
} else {
this.navigationService.routeToSecretsTab()
}
return
}

Expand All @@ -62,4 +67,26 @@ export class SecretAddPage {
public async togglePasscode(): Promise<void> {
this.secret.isParanoia = !this.secret.isParanoia
}

private async showErrorAlert() {
const alert = await this.uiEventService.getTranslatedAlert({
header: 'secret-edit.error_alert.title',
message: 'secret-edit.error_alert.message',
backdropDismiss: true,
buttons: [
{
text: 'secret-edit.error_alert.abort-button_label',
handler: () => {
this.navigationService.routeToSecretsTab()
}
},
{
text: 'secret-edit.error_alert.retry-button_label',
role: 'cancel'
}
]
})

await alert.present().catch(handleErrorLocal(ErrorCategory.IONIC_ALERT))
}
}
8 changes: 7 additions & 1 deletion src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,13 @@
"copied": "Recovery key copied",
"reset-error": "Could not set the recovery key"
},
"confirm_label": "Confirm"
"confirm_label": "Confirm",
"error_alert": {
"title": "Error",
"message": "Something went wrong!",
"abort-button_label": "Abort",
"retry-button_label": "Retry"
}
},
"secret-service": {
"alert": {
Expand Down

0 comments on commit 3dbc816

Please sign in to comment.