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!364
  • Loading branch information
AndreasGassmann committed Oct 14, 2022
2 parents 1cc5654 + 53c38b0 commit cfa17a2
Show file tree
Hide file tree
Showing 314 changed files with 4,379 additions and 3,103 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ COPY install-test-deps.js /app
COPY package.json /app
COPY yarn.lock /app
COPY apply-diagnostic-modules.js /app
COPY fix-qrscanner-gradle.js /app

RUN yarn install-test-dependencies

Expand Down
8 changes: 5 additions & 3 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ android {
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = '1.8'
jvmTarget = '11'
}
lintOptions {
abortOnError false
Expand All @@ -52,6 +52,8 @@ repositories {
}

dependencies {
implementation "androidx.core:core-splashscreen:$coreSplashScreenVersion"
implementation "androidx.coordinatorlayout:coordinatorlayout:$androidxCoordinatorLayoutVersion"
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
Expand Down
6 changes: 3 additions & 3 deletions android/app/capacitor.build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
}

Expand All @@ -18,7 +18,7 @@ dependencies {
implementation "com.android.support:support-v4:26.+"
implementation "com.android.support:appcompat-v7:26.+"
}
apply from: "../../node_modules/cordova-plugin-qrscanner/src/android/qrscanner.gradle"
apply from: "../../node_modules/cordova-plugin-qrscanner-11/src/android/qrscanner.gradle"

if (hasProperty('postBuildExtras')) {
postBuildExtras()
Expand Down
18 changes: 6 additions & 12 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="it.airgap.vault">

<?xml version="1.0" encoding="utf-8" ?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="it.airgap.vault">
<application
android:allowBackup="false"
android:icon="@mipmap/icon"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:networkSecurityConfig="@xml/network_security_config"
android:theme="@style/AppTheme">

android:theme="@style/AppTheme"
android:roundIcon="@mipmap/ic_launcher_round">
<activity
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode"
android:name="it.airgap.vault.MainActivity"
Expand All @@ -18,7 +16,6 @@
android:theme="@style/AppTheme.NoActionBarLaunch"
android:exported="true"
android:launchMode="singleTask">

<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand All @@ -30,17 +27,14 @@
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="@string/custom_url_scheme" />
</intent-filter>

</activity>

<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths" />
</provider>
</application>

Expand Down
4 changes: 2 additions & 2 deletions android/app/src/main/java/it/airgap/vault/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
public class MainActivity extends BridgeActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

registerPlugin(CameraPreview.class);
registerPlugin(AppInfo.class);
registerPlugin(SecurityUtils.class);
registerPlugin(SaplingNative.class);

super.onCreate(savedInstanceState);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ import it.airgap.vault.plugin.PluginError
import it.airgap.vault.plugin.securityutils.authprompt.AuthPromptFragment
import it.airgap.vault.plugin.securityutils.storage.Storage
import it.airgap.vault.util.*
import kotlinx.coroutines.Deferred
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
import kotlinx.coroutines.withContext
import java.util.*
import kotlin.coroutines.resume
import kotlin.coroutines.suspendCoroutine

@CapacitorPlugin(requestCodes = [SecurityUtils.REQUEST_CODE_CONFIRM_DEVICE_CREDENTIALS])
class SecurityUtils : Plugin() {
Expand Down Expand Up @@ -381,45 +381,47 @@ class SecurityUtils : Plugin() {
authenticateOrContinue(AuthOrigin.VAULT, lastCall, { lastCallbackId?.let { releaseCallIfKept(it) } }, { authenticateOrContinueOnResume(); false })
}

private suspend fun showAuthenticationScreen(onAuthenticated: (() -> Unit)? = null, onFailure: (() -> Boolean)? = null) = suspendCoroutine<Unit> { continuation ->
private suspend fun showAuthenticationScreen(onAuthenticated: (() -> Unit)? = null, onFailure: (() -> Boolean)? = null) {
val containerView = FragmentContainerView(context).apply { id = R.id.authPromptFragmentContainerView }
val layoutParams = FrameLayout.LayoutParams(
FrameLayout.LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams.MATCH_PARENT,
)

activity.runOnUiThread {
bridge.webView.parent.addView(containerView, layoutParams)
coroutineScope {
withContext(Dispatchers.Main) {
bridge.webView.parent.addView(containerView, layoutParams)

val fragment = AuthPromptFragment()
val fragment = AuthPromptFragment()

activity.supportFragmentManager.commit {
setReorderingAllowed(true)
replace(containerView.id, fragment)
addToBackStack(null)
}
activity.supportFragmentManager.commit {
setReorderingAllowed(true)
replace(containerView.id, fragment)
addToBackStack(null)
}

fragment.resultLiveData.observe(activity) {
isAuthenticated = it
lastBackgroundDate = null
withContext(Dispatchers.Default) {
val isAuthenticated = fragment.resultDeferred.await()

val handled = if (it) {
onAuthenticated?.invoke()
true
} else {
onFailure?.invoke() ?: true
}
this@SecurityUtils.isAuthenticated = isAuthenticated
this@SecurityUtils.lastBackgroundDate = null

val handled = if (isAuthenticated) {
onAuthenticated?.invoke()
true
} else {
onFailure?.invoke() ?: true
}

if (handled) {
activity.runOnUiThread {
activity.supportFragmentManager.commit {
remove(fragment)
if (handled) {
launch(Dispatchers.Main) {
activity.supportFragmentManager.commit {
remove(fragment)
}
bridge.webView.parent.removeView(activity.findViewById(containerView.id))
}
bridge.webView.parent.removeView(activity.findViewById(containerView.id))
}
}

continuation.resume(Unit)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import androidx.biometric.BiometricManager
import androidx.biometric.BiometricPrompt
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import it.airgap.vault.R
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.Deferred

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

private val _resultLiveData: MutableLiveData<Boolean> = MutableLiveData()
val resultLiveData: LiveData<Boolean>
get() = _resultLiveData
private val _resultDeferred: CompletableDeferred<Boolean> = CompletableDeferred()
val resultDeferred: Deferred<Boolean>
get() = _resultDeferred

private var _biometricPromptInfo: BiometricPrompt.PromptInfo? = null
private val biometricPromptInfo: BiometricPrompt.PromptInfo
Expand All @@ -28,22 +28,22 @@ class AuthPromptFragment : Fragment(R.layout.fragment_authenticator) {
private var _biometricPrompt: BiometricPrompt? = null
private val biometricPrompt: BiometricPrompt
get() = _biometricPrompt ?: run {
val executor = ContextCompat.getMainExecutor(context)
val executor = ContextCompat.getMainExecutor(requireContext())

BiometricPrompt(this, executor, object : BiometricPrompt.AuthenticationCallback() {
override fun onAuthenticationError(errorCode: Int, errString: CharSequence) {
super.onAuthenticationError(errorCode, errString)
_resultLiveData.postValue(false)
_resultDeferred.complete(false)
}

override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) {
super.onAuthenticationSucceeded(result)
_resultLiveData.postValue(true)
_resultDeferred.complete(true)
}

override fun onAuthenticationFailed() {
super.onAuthenticationFailed()
_resultLiveData.postValue(false)
_resultDeferred.complete(false)
}
})
}.also { _biometricPrompt = it }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,8 @@ class Storage(private val context: Context, private val storageAlias: String, pr
}

private fun generatePasswordKey(passwordFile: SecureFile, passphraseOrPin: String) {
if (passphraseOrPin.isBlank()) return

val salt = ByteArray(Constants.KEY_SIZE / 8).also { SecureRandom().nextBytes(it) }
val inputSecretKey = generateSecretKey(passphraseOrPin, salt)

Expand Down
14 changes: 14 additions & 0 deletions android/app/src/main/res/drawable-night/splash_icon.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="289dp"
android:height="288dp"
android:viewportWidth="289"
android:viewportHeight="288">
<path
android:pathData="M164.07,216.31C188.76,205.68 208.02,181.1 210.62,156.2C213.18,131.67 210.48,98.58 210.36,97.18L209.98,92.66L205.62,91.41C205.49,91.38 192.94,87.78 183.83,83.9C172.3,78.98 160.64,72.23 160.52,72.16L152.73,67.62C151.81,67.09 150.66,67.75 150.66,68.81L150.66,77.84C150.66,80.35 152.07,82.53 154.14,83.63C155.89,84.63 167.13,91.04 178.68,95.97C185.12,98.72 192.84,101.24 197.6,102.71C198.24,112.52 199.47,136.62 197.57,154.84C196.49,165.18 191.6,176.02 183.81,185.37C178.21,192.08 171.4,197.7 164.07,201.72L164.07,216.31Z"
android:fillColor="#6B6C6E"
android:fillType="nonZero"/>
<path
android:pathData="M144.58,167.48L133.89,167.48C129.17,167.48 125.34,163.57 125.48,158.81C125.62,154.24 129.49,150.66 134.07,150.66L154.43,150.66C166.28,150.66 176.12,141.19 176.24,129.34C176.35,117.36 166.65,107.59 154.7,107.59L144.46,107.65C140.95,107.64 138.1,104.78 138.1,101.26L138.1,68.91C138.1,67.85 136.96,67.19 136.04,67.72L128.27,72.17C128.15,72.24 116.35,78.99 104.72,83.92C95.57,87.81 83.13,91.38 83.01,91.41L78.62,92.67L78.27,97.22C78.16,98.63 75.66,131.97 78.22,156.48C79.57,169.37 85.5,182.66 94.92,193.9C104.14,204.89 116.27,213.44 129.06,217.97L135.98,220.42C136.88,220.73 137.81,220.07 137.81,219.13L137.81,211.78C137.81,208.87 135.91,206.39 133.28,205.54C122.72,201.76 112.67,194.64 104.98,185.46C97.22,176.21 92.35,165.43 91.27,155.12C89.37,136.89 90.48,112.59 91.06,102.7C95.78,101.24 103.42,98.73 109.85,96C115.26,93.71 120.61,91.09 124.97,88.85L124.97,101.26C124.97,112.02 133.72,120.77 144.48,120.77L154.72,120.71C159.44,120.72 163.26,124.63 163.11,129.38C162.97,133.96 159.1,137.53 154.52,137.53L133.89,137.53C121.95,137.53 112.24,147.31 112.36,159.28C112.47,171.14 122.31,180.6 134.17,180.6L144.58,180.6C148.1,180.6 150.97,183.47 150.97,186.98C150.97,186.98 150.94,207.56 150.94,211.84L150.94,219.19C150.94,220.13 151.88,220.8 152.77,220.48L159.69,218.03C161.17,217.51 162.63,216.93 164.07,216.31L164.07,186.24C163.67,175.83 155.09,167.48 144.58,167.48"
android:fillColor="#ffffff"
android:fillType="nonZero"/>
</vector>
34 changes: 0 additions & 34 deletions android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
<solid android:color="@color/background_screen" />
</shape>
</item>
<item android:drawable="@drawable/logo_splash" android:gravity="center" />
</layer-list>
<item android:drawable="@drawable/splash_icon" android:gravity="center" />
</layer-list>
Loading

0 comments on commit cfa17a2

Please sign in to comment.