Skip to content

Commit

Permalink
Merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
Juliano1612 committed Aug 26, 2024
2 parents 6f818cc + 157e47f commit b799386
Show file tree
Hide file tree
Showing 49 changed files with 185 additions and 76 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -335,3 +335,5 @@ $RECYCLE.BIN/
!gradle/wrapper/gradle-wrapper.jar

# End of https://www.gitignore.io/api/java,linux,macos,windows,android,intellij,androidstudio

kls_database.db
File renamed without changes.
16 changes: 8 additions & 8 deletions WalletSdk/build.gradle.kts → MobileSdk/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ publishing {
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/spruceid/wallet-sdk-kt")
url = uri("https://maven.pkg.github.com/spruceid/mobile-sdk-kt")
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
Expand All @@ -20,8 +20,8 @@ publishing {
publications {
// Creates a Maven publication called "release".
create<MavenPublication>("release") {
groupId = "com.spruceid.wallet.sdk"
artifactId = "walletsdk"
groupId = "com.spruceid.mobile.sdk"
artifactId = "mobilesdk"
version = System.getenv("VERSION")

afterEvaluate {
Expand All @@ -30,9 +30,9 @@ publishing {

pom {
packaging = "aar"
name.set("walletsdk")
description.set("Android SpruceID Wallet SDK")
url.set("https://github.com/spruceid/wallet-sdk-kt")
name.set("mobilesdk")
description.set("Android SpruceID Mobile SDK")
url.set("https://github.com/spruceid/mobile-sdk-kt")
licenses {
license {
name.set("MIT License")
Expand Down Expand Up @@ -76,7 +76,7 @@ nmcp {


android {
namespace = "com.spruceid.wallet.sdk"
namespace = "com.spruceid.mobile.sdk"
compileSdk = 33

defaultConfig {
Expand Down Expand Up @@ -118,7 +118,7 @@ android {
}

dependencies {
api("com.spruceid.wallet.sdk.rs:walletsdkrs:0.0.25")
api("com.spruceid.mobile.sdk.rs:mobilesdkrs:0.0.26")
//noinspection GradleCompatible
implementation("com.android.support:appcompat-v7:28.0.0")
/* Begin UI dependencies */
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.CAMERA" />

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.spruceid.wallet.sdk
package com.spruceid.mobile.sdk

open class BaseCredential {
private var id: String?
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.spruceid.wallet.sdk
package com.spruceid.mobile.sdk

import android.bluetooth.le.*
import android.os.Handler
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.spruceid.wallet.sdk
package com.spruceid.mobile.sdk

import android.bluetooth.le.ScanResult

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.spruceid.wallet.sdk
package com.spruceid.mobile.sdk

import android.bluetooth.BluetoothAdapter
import android.bluetooth.le.AdvertiseCallback
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.spruceid.wallet.sdk
package com.spruceid.mobile.sdk

import android.bluetooth.BluetoothManager
import android.util.Log
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.spruceid.wallet.sdk
package com.spruceid.mobile.sdk

enum class BleStates(val string: String) {
Scanning("scanning"),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package com.spruceid.mobile.sdk

import android.content.Context
import android.content.Context.CONNECTIVITY_SERVICE
import android.net.ConnectivityManager
import android.net.Network
import android.net.NetworkCapabilities.NET_CAPABILITY_INTERNET
import android.net.NetworkCapabilities.TRANSPORT_CELLULAR
import android.net.NetworkCapabilities.TRANSPORT_WIFI
import android.net.NetworkRequest
import androidx.lifecycle.LiveData
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import java.io.IOException
import java.net.InetSocketAddress
import javax.net.SocketFactory

class ConnectionLiveData(context: Context) : LiveData<Boolean>() {

private lateinit var networkCallback: ConnectivityManager.NetworkCallback
private val connectivityManager =
context.getSystemService(CONNECTIVITY_SERVICE) as ConnectivityManager
private val validNetworks: MutableSet<Network> = HashSet()

private fun checkValidNetworks() {
postValue(validNetworks.size > 0)
}

override fun onActive() {
networkCallback = createNetworkCallback()
val networkRequest = NetworkRequest.Builder()
.addCapability(NET_CAPABILITY_INTERNET)
.addTransportType(TRANSPORT_WIFI)
.addTransportType(TRANSPORT_CELLULAR)
.build()
connectivityManager.registerNetworkCallback(networkRequest, networkCallback)
}

override fun onInactive() {
connectivityManager.unregisterNetworkCallback(networkCallback)
}

private fun createNetworkCallback() = object : ConnectivityManager.NetworkCallback() {

override fun onAvailable(network: Network) {
val networkCapabilities = connectivityManager.getNetworkCapabilities(network)
val hasInternetCapability = networkCapabilities?.hasCapability(NET_CAPABILITY_INTERNET)

if (hasInternetCapability == true) {
// Check if this network actually has internet
CoroutineScope(Dispatchers.IO).launch {
val hasInternet = DoesNetworkHaveInternet.execute(network.socketFactory)
if (hasInternet) {
withContext(Dispatchers.Main) {
validNetworks.add(network)
checkValidNetworks()
}
}
}
}
}

override fun onLost(network: Network) {
validNetworks.remove(network)
checkValidNetworks()
}
}

object DoesNetworkHaveInternet {
suspend fun execute(socketFactory: SocketFactory): Boolean {
// Make sure to execute this on a background thread.
delay(1000)
return try {
val socket = socketFactory.createSocket() ?: throw IOException("Socket is null.")
socket.connect(InetSocketAddress("8.8.8.8", 53), 1500)
socket.close()
true
} catch (e: IOException) {
false
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.spruceid.wallet.sdk
package com.spruceid.mobile.sdk

import java.security.KeyFactory
import java.security.KeyStore
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.spruceid.wallet.sdk
package com.spruceid.mobile.sdk

import android.bluetooth.BluetoothManager
import android.util.Log
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.spruceid.wallet.sdk
package com.spruceid.mobile.sdk

import android.bluetooth.BluetoothDevice
import android.bluetooth.BluetoothGatt
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.spruceid.wallet.sdk
package com.spruceid.mobile.sdk

abstract class GattClientCallback {
open fun onPeerConnected() {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.spruceid.wallet.sdk
package com.spruceid.mobile.sdk


import android.bluetooth.*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.spruceid.wallet.sdk
package com.spruceid.mobile.sdk

abstract class GattServerCallback {
open fun onPeerConnected() {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.spruceid.wallet.sdk
package com.spruceid.mobile.sdk

import android.os.Build
import android.security.keystore.KeyGenParameterSpec
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.spruceid.wallet.sdk
package com.spruceid.mobile.sdk

/**
* The Keystore environment used for the key generation.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.spruceid.wallet.sdk
package com.spruceid.mobile.sdk

import android.util.Log
import com.spruceid.mobile.sdk.rs.MDoc as InnerMDoc
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.spruceid.wallet.sdk
package com.spruceid.mobile.sdk

import android.bluetooth.BluetoothManager
import android.util.Log
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.spruceid.wallet.sdk
package com.spruceid.mobile.sdk

import android.bluetooth.BluetoothManager
import android.util.Log
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.spruceid.wallet.sdk
package com.spruceid.mobile.sdk

import android.app.Activity
import android.bluetooth.BluetoothAdapter
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.spruceid.wallet.sdk
package com.spruceid.mobile.sdk
import android.app.Activity
import android.bluetooth.BluetoothAdapter
import android.bluetooth.BluetoothManager
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.spruceid.wallet.sdk
package com.spruceid.mobile.sdk


fun hexToByteArray(value: String): ByteArray {
Expand Down Expand Up @@ -27,4 +27,4 @@ enum class PresentmentState {

/// App should display a success message and offer to close the page
SUCCESS,
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.spruceid.wallet.sdk
package com.spruceid.mobile.sdk

import org.json.JSONObject

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.spruceid.wallet.sdk.ui
package com.spruceid.mobile.sdk.ui

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.IntrinsicSize
Expand All @@ -8,7 +8,7 @@ import androidx.compose.foundation.layout.height
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import com.spruceid.wallet.sdk.CredentialPack
import com.spruceid.mobile.sdk.CredentialPack

/**
* Data class with the specification to display the credential pack in a list view
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.spruceid.wallet.sdk.ui
package com.spruceid.mobile.sdk.ui

import android.content.Context
import android.util.Range
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.spruceid.wallet.sdk.ui
package com.spruceid.mobile.sdk.ui

import androidx.camera.core.ImageAnalysis.COORDINATE_SYSTEM_ORIGINAL
import androidx.camera.mlkit.vision.MlKitAnalyzer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.spruceid.wallet.sdk.ui
package com.spruceid.mobile.sdk.ui

import android.graphics.ImageFormat
import android.os.Build
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.spruceid.wallet.sdk.ui
package com.spruceid.mobile.sdk.ui

import android.graphics.ImageFormat
import android.os.Build
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.spruceid.wallet.sdk
package com.spruceid.mobile.sdk

import org.junit.Test

Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Kotlin Wallet SDK
# Kotlin Mobile SDK

## Maturity Disclaimer

In its current version, Wallet SDK has not yet undergone a formal security audit
In its current version, Mobile SDK has not yet undergone a formal security audit
to desired levels of confidence for suitable use in production systems. This
implementation is currently suitable for exploratory work and experimentation
only. We welcome feedback on the usability, architecture, and security of this
Expand All @@ -11,7 +11,7 @@ security firm before the v1.0 release.

## Architecture

Our Wallet SDKs use shared code, with most of the logic being written once in
Our Mobile SDKs use shared code, with most of the logic being written once in
Rust, and when not possible, native APIs (e.g. Bluetooth, OS Keychain) are
called in native SDKs.

Expand All @@ -30,6 +30,6 @@ called in native SDKs.
│Rust│
└────┘
```
- [Kotlin SDK](https://github.com/spruceid/wallet-sdk-kt)
- [Swift SDK](https://github.com/spruceid/wallet-sdk-swift)
- [Rust layer](https://github.com/spruceid/wallet-sdk-rs)
- [Kotlin SDK](https://github.com/spruceid/mobile-sdk-kt)
- [Swift SDK](https://github.com/spruceid/mobile-sdk-swift)
- [Rust layer](https://github.com/spruceid/mobile-sdk-rs)
6 changes: 3 additions & 3 deletions example/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ plugins {
}

android {
namespace = "com.spruceid.walletsdkexample"
namespace = "com.spruceid.mobilesdkexample"
compileSdk = 34

defaultConfig {
applicationId = "com.spruceid.walletsdkexample"
applicationId = "com.spruceid.mobilesdkexample"
minSdk = 26
targetSdk = 34
versionCode = 1
Expand Down Expand Up @@ -59,7 +59,7 @@ dependencies {
implementation("androidx.compose.ui:ui-graphics")
implementation("androidx.compose.ui:ui-tooling-preview")
implementation("androidx.compose.material3:material3")
implementation(project(mapOf("path" to ":WalletSdk")))
implementation(project(mapOf("path" to ":MobileSdk")))
implementation("com.google.zxing:core:3.5.1")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.spruceid.walletsdkexample
package com.spruceid.mobilesdkexample

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4
Expand All @@ -19,6 +19,6 @@ class ExampleInstrumentedTest {
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.spruceid.walletsdk", appContext.packageName)
assertEquals("com.spruceid.mobilesdk", appContext.packageName)
}
}
Loading

0 comments on commit b799386

Please sign in to comment.