Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 1 addition & 13 deletions MultipazCodelab/Holder/androidApp/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -120,19 +120,7 @@
requests on the lock screen because there is no PII. For an app with real
user data it might be a privacy problem to show PII on the lock screen.
-->
<service
android:name="org.multipaz.samples.wallet.cmp.UtopiaNfcService"
android:exported="true"
android:label="@string/nfc_ndef_service_description"
android:permission="android.permission.BIND_NFC_SERVICE">
<intent-filter>
<action android:name="android.nfc.cardemulation.action.HOST_APDU_SERVICE" />
</intent-filter>

<meta-data
android:name="android.nfc.cardemulation.host_apdu_service"
android:resource="@xml/nfc_ndef_service" />
</service>
<!-- TODO: Add this NfcService-->
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,8 @@ class MainActivity : FragmentActivity() {
/**
* Handle a link (either a app link, universal link, or custom URL schema link).
*/
//TODO: implement HandleUrl for Android
fun handleUrl(url: String) {
handleUrl(
url = url,
credentialOffers = credentialOffers,
provisioningModel = provisioningModel,
provisioningSupport = provisioningSupport,
)
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
android:requireDeviceScreenOn="false"
tools:ignore="UnusedAttribute">

<aid-group android:description="@string/nfc_ndef_service_aid_group_description" android:category="other">
<!-- NFC Type 4 Tag -->
<aid-filter android:name="D2760000850101"/>
</aid-group>
<!--TODO: implement nfc_ndef_service xml-->

</host-apdu-service>
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package org.multipaz.samples.wallet.cmp.ui

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
Expand All @@ -28,7 +26,6 @@ import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalUriHandler
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
Expand All @@ -42,15 +39,10 @@ import org.multipaz.compose.presentment.MdocProximityQrPresentment
import org.multipaz.compose.presentment.MdocProximityQrSettings
import org.multipaz.compose.prompt.PromptDialogs
import org.multipaz.compose.qrcode.generateQrCode
import org.multipaz.mdoc.connectionmethod.MdocConnectionMethod
import org.multipaz.mdoc.connectionmethod.MdocConnectionMethodBle
import org.multipaz.mdoc.connectionmethod.MdocConnectionMethodNfc
import org.multipaz.mdoc.transport.MdocTransportOptions
import org.multipaz.presentment.PresentmentSource
import org.multipaz.prompt.PromptModel
import org.multipaz.samples.wallet.cmp.util.AppSettingsModel
import org.multipaz.util.Logger
import org.multipaz.util.UUID
import kotlin.time.Duration.Companion.seconds

private const val TAG = "AccountScreen"
Expand Down Expand Up @@ -243,58 +235,7 @@ private fun ShowQrButton(
) {
when (hasCredentials) {
true -> {
Button(onClick = {
val connectionMethods = mutableListOf<MdocConnectionMethod>()
val bleUuid = UUID.randomUUID()
if (bleCentralClientEnabled) {
connectionMethods.add(
MdocConnectionMethodBle(
supportsPeripheralServerMode = false,
supportsCentralClientMode = true,
peripheralServerModeUuid = null,
centralClientModeUuid = bleUuid,
),
)
}
if (blePeripheralServerEnabled) {
connectionMethods.add(
MdocConnectionMethodBle(
supportsPeripheralServerMode = true,
supportsCentralClientMode = false,
peripheralServerModeUuid = bleUuid,
centralClientModeUuid = null,
),
)
}
if (nfcDataTransferEnabled) {
connectionMethods.add(
MdocConnectionMethodNfc(
commandDataFieldMaxLength = 0xffff,
responseDataFieldMaxLength = 0x10000,
),
)
}
onGenerateQrCode(
MdocProximityQrSettings(
availableConnectionMethods = connectionMethods,
createTransportOptions =
MdocTransportOptions(
bleUseL2CAP = bleL2CapEnabled,
bleUseL2CAPInEngagement = bleL2CapInEngagementEnabled,
),
),
)
}) {
Text("Present mDL via QR")
}
Spacer(modifier = Modifier.height(16.dp))
Text(
text =
"The mDL is also available\n" +
"via NFC engagement and W3C DC API\n" +
"(Android-only right now)",
textAlign = TextAlign.Center,
)
// TODO: show qr button when credentials are available
}

false -> {
Expand Down Expand Up @@ -332,12 +273,7 @@ private fun ShowQrCode(
horizontalAlignment = Alignment.CenterHorizontally,
) {
Text(text = "Present QR code to mdoc reader")
Image(
modifier = Modifier.fillMaxWidth(),
bitmap = qrCodeBitmap,
contentDescription = null,
contentScale = ContentScale.FillWidth,
)
// TODO: show QR code
Button(onClick = { onReset() }) {
Text("Cancel")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import org.koin.compose.koinInject
import org.multipaz.provisioning.AuthorizationChallenge
import org.multipaz.provisioning.AuthorizationResponse
import org.multipaz.provisioning.ProvisioningModel
import org.multipaz.samples.wallet.cmp.util.ProvisioningSupport
import org.multipaz.util.Logger
Expand Down Expand Up @@ -92,26 +91,7 @@ fun ProvisioningTestScreen(
}

else -> {
val text =
when (provisioningState) {
ProvisioningModel.Idle -> "Initializing..."
ProvisioningModel.Initial -> "Starting provisioning..."
ProvisioningModel.Connected -> "Connected to the back-end"
ProvisioningModel.ProcessingAuthorization -> "Processing authorization..."
ProvisioningModel.Authorized -> "Authorized"
ProvisioningModel.RequestingCredentials -> "Requesting credentials..."
is ProvisioningModel.CredentialsIssued -> "Credentials issued"
is ProvisioningModel.Error -> throw IllegalStateException()
is ProvisioningModel.Authorizing -> throw IllegalStateException()
}
Text(
modifier =
Modifier
.align(Alignment.CenterHorizontally)
.padding(8.dp),
style = MaterialTheme.typography.titleLarge,
text = text,
)
// TODO: update text depends on provisioningState
}
}
}
Expand All @@ -130,11 +110,7 @@ private fun Authorize(
EVIDENCE_REQUEST_WEB_VIEW,
"Authorize: Rendering EvidenceRequestWebView for OAuth challenge",
)
EvidenceRequestWebView(
evidenceRequest = challenge,
provisioningModel = provisioningModel,
provisioningSupport = provisioningSupport,
)
// TODO: init EvidenceRequestWebView
}

is AuthorizationChallenge.SecretText -> TODO()
Expand Down Expand Up @@ -178,9 +154,7 @@ fun EvidenceRequestWebView(
EVIDENCE_REQUEST_WEB_VIEW,
"EvidenceRequestWebView LaunchedEffect invokedUrl: $invokedUrl",
)
provisioningModel.provideAuthorizationResponse(
AuthorizationResponse.OAuth(stableEvidenceRequest.id, invokedUrl),
)
// TODO: add provideAuthorizationResponse
}
val uriHandler = LocalUriHandler.current
LaunchedEffect(stableEvidenceRequest.url) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@ class OpenID4VCILocalBackend : OpenID4VCIBackend {
override suspend fun getClientId(): String = CLIENT_ID

override suspend fun createJwtClientAssertion(authorizationServerIdentifier: String): String =
OpenID4VCIBackendUtil.createJwtClientAssertion(
signingKey = clientAssertionKey,
clientId = CLIENT_ID,
authorizationServerIdentifier = authorizationServerIdentifier,
)
// TODO: create and assign JWT client assertion string
TODO()

override suspend fun createJwtWalletAttestation(keyAttestation: KeyAttestation): String =
OpenID4VCIBackendUtil.createWalletAttestation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ class ProvisioningSupport(

suspend fun processAppLinkInvocation(url: String) {
val state = Url(url).parameters["state"] ?: ""
lock.withLock {
pendingLinksByState.remove(state)?.send(url)
}
// TODO: process app link invocation
}

suspend fun waitForAppLinkInvocation(state: String): String {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
package org.multipaz.samples.wallet.cmp.util

import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.launch
import org.multipaz.provisioning.ProvisioningModel
import org.multipaz.util.Logger

private const val TAG = "UrlHandler"
private const val OID4VCI_CREDENTIAL_OFFER_URL_SCHEME = "openid-credential-offer://"
Expand All @@ -26,42 +22,5 @@ fun handleUrl(
provisioningModel: ProvisioningModel,
provisioningSupport: ProvisioningSupport,
) {
Logger.i(TAG, "handleUrl called with: $url")
Logger.i(TAG, "handleUrl provisioningModel state: ${provisioningModel.state.value}")

if (url.startsWith(OID4VCI_CREDENTIAL_OFFER_URL_SCHEME) ||
url.startsWith(HAIP_URL_SCHEME)
) {
val queryIndex = url.indexOf('?')
if (queryIndex >= 0) {
Logger.i(TAG, "Starting OpenID4VCI provisioning with: $url")
Logger.i(
TAG,
"OID4VCI_CREDENTIAL_OFFER_URL_SCHEME provisioningModel: $provisioningModel",
)
Logger.i(TAG, "handleUrl: Sending credential offer to channel...")
CoroutineScope(Dispatchers.Default).launch {
Logger.i(TAG, "handleUrl: About to send to credentialOffers channel")
credentialOffers.send(url)
Logger.i(TAG, "handleUrl: Successfully sent to credentialOffers channel")
}
Logger.i(
TAG,
"handleUrl: Credential offer sent to channel, LaunchedEffect should process it",
)
}
} else if (url.startsWith(ProvisioningSupport.APP_LINK_BASE_URL)) {
Logger.i(TAG, "APP_LINK_BASE_URL provisioningModel: $provisioningModel")
Logger.i(TAG, "Processing app link invocation: $url")

CoroutineScope(Dispatchers.Default).launch {
try {
Logger.i(TAG, "handleUrl: About to process app link invocation")
provisioningSupport.processAppLinkInvocation(url)
Logger.i(TAG, "handleUrl: App link invocation processed successfully")
} catch (e: Exception) {
Logger.e(TAG, "Error processing app link: ${e.message}", e)
}
}
}
// TODO: Implement URL handling and validation
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,26 +94,7 @@ fun MainViewController() =
*/
@Suppress("FunctionName") // Swift interop: follows Swift naming convention for exported functions
fun HandleUrl(url: String) {
val credentialOffers = globalCredentialOffers
if (credentialOffers == null) {
Logger.w(TAG, "HandleUrl: credentialOffers channel not yet initialized, URL will be ignored: $url")
return
}

try {
val koinHelper = object : KoinComponent { }
val provisioningModel = koinHelper.get<ProvisioningModel>()
val provisioningSupport = koinHelper.get<ProvisioningSupport>()

org.multipaz.samples.wallet.cmp.util.handleUrl(
url = url,
credentialOffers = credentialOffers,
provisioningModel = provisioningModel,
provisioningSupport = provisioningSupport,
)
} catch (e: Exception) {
Logger.e(TAG, "Error in HandleUrl: ${e.message}", e)
}
// TODO: implement HandleUrl for iOS
}

@Suppress("FunctionName") // Swift interop naming
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,6 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_ASSET_PATHS = "\"iosApp/Preview Content\"";
DEVELOPMENT_TEAM = 4G3ATA5MLV;
ENABLE_PREVIEWS = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
Expand Down Expand Up @@ -461,7 +460,6 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_ASSET_PATHS = "\"iosApp/Preview Content\"";
DEVELOPMENT_TEAM = 4G3ATA5MLV;
ENABLE_PREVIEWS = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
Expand Down Expand Up @@ -499,7 +497,6 @@
CODE_SIGN_ENTITLEMENTS = IdentityDocumentProviderExtension/IdentityDocumentProviderExtension.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 4G3ATA5MLV;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
Expand Down Expand Up @@ -537,7 +534,6 @@
CODE_SIGN_ENTITLEMENTS = IdentityDocumentProviderExtension/IdentityDocumentProviderExtension.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 4G3ATA5MLV;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
Expand Down
Loading