Skip to content

Commit 8ca302a

Browse files
committed
Remove legacy Chrome (< v138) support
1 parent 6b350ff commit 8ca302a

File tree

4 files changed

+5
-61
lines changed

4 files changed

+5
-61
lines changed

app/src/main/java/com/credman/cmwallet/CmWalletApplication.kt

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,6 @@ class CmWalletApplication : Application() {
8585
applicationScope.launch {
8686
credentialRepo.credentialRegistryDatabase.collect { credentialDatabase ->
8787
Log.i(TAG, "Credentials changed $credentialDatabase")
88-
// Oid4vp draft 24
89-
// For backward compatibility with Chrome
90-
registryManager.registerCredentials(
91-
request = object : RegisterCredentialsRequest(
92-
"com.credman.IdentityCredential",
93-
"openid4vp",
94-
credentialDatabase,
95-
openId4VPDraft24Matcher
96-
) {}
97-
)
98-
// In the future, should only register this type
9988
registryManager.registerCredentials(
10089
request = object : RegisterCredentialsRequest(
10190
DigitalCredential.TYPE_DIGITAL_CREDENTIAL,
@@ -104,18 +93,6 @@ class CmWalletApplication : Application() {
10493
openId4VPDraft24Matcher
10594
) {}
10695
)
107-
108-
// Oid4vp 1.0 Candidate
109-
// For backward compatibility with Chrome
110-
registryManager.registerCredentials(
111-
request = object : RegisterCredentialsRequest(
112-
"com.credman.IdentityCredential",
113-
"openid4vp1.0",
114-
credentialDatabase,
115-
openId4VP1_0Matcher
116-
) {}
117-
)
118-
// In the future, should only register this type
11996
registryManager.registerCredentials(
12097
request = object : RegisterCredentialsRequest(
12198
DigitalCredential.TYPE_DIGITAL_CREDENTIAL,

app/src/main/java/com/credman/cmwallet/data/repository/CredentialRepository.kt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,6 @@ class CredentialRepository {
9090
PnvTokenRegistry.TEST_PNV_2_VERIFY_PHONE_NUMBER
9191
)
9292

93-
// For chrome < 138. Should be removed soon
94-
registryManager.registerCredentials(
95-
request = object : RegisterCredentialsRequest(
96-
"com.credman.IdentityCredential",
97-
"openid4vp1.0-pnv",
98-
PnvTokenRegistry.buildRegistryDatabase(testPhoneNumberTokens),
99-
pnvMatcher
100-
) {}
101-
)
102-
// For native apps and chrome 138+
10393
registryManager.registerCredentials(
10494
request = object : RegisterCredentialsRequest(
10595
DigitalCredential.TYPE_DIGITAL_CREDENTIAL,

app/src/main/java/com/credman/cmwallet/getcred/GetCredentialActivity.kt

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ import com.credman.cmwallet.openid4vp.OpenId4VPMatchedSdJwtClaims
4444
import com.credman.cmwallet.pnv.maybeHandlePnv
4545
import com.credman.cmwallet.sdjwt.SdJwt
4646
import com.credman.cmwallet.toBase64UrlNoPadding
47-
import com.google.android.gms.identitycredentials.Credential
48-
import com.google.android.gms.identitycredentials.IntentHelper
4947
import org.json.JSONArray
5048
import org.json.JSONObject
5149

@@ -135,10 +133,9 @@ fun createOpenID4VPResponse(
135133
val response = openId4VPRequest.generateResponse(vpToken)
136134
Log.d(TAG, "Returning $response")
137135
return DigitalCredentialResult(
138-
responseJsonLegacy = response,
139136
authenticationTitle = authenticationTitle,
140137
authenticationSubtitle = authenticationSubtitle,
141-
responseJsonModern = JSONObject().apply {
138+
responseJson = JSONObject().apply {
142139
put("protocol", openId4VPRequest.protocolIdentifier)
143140
put("data", JSONObject(response))
144141
}.toString()
@@ -263,7 +260,7 @@ class GetCredentialActivity : FragmentActivity() {
263260
if (pnvResponse != null) {
264261
PendingIntentHandler.setGetCredentialResponse(
265262
resultData,
266-
GetCredentialResponse(DigitalCredential(pnvResponse.responseJsonModern))
263+
GetCredentialResponse(DigitalCredential(pnvResponse.responseJson))
267264
)
268265
setResult(RESULT_OK, resultData)
269266
finish()
@@ -292,24 +289,9 @@ class GetCredentialActivity : FragmentActivity() {
292289
override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) {
293290
Log.d(TAG, "onAuthenticationSucceeded")
294291

295-
// This is a temporary solution until Chrome migrate to use
296-
// the top level DC DigitalCredential json structure.
297-
// Long term, this should be replaced by a simple
298-
// `PendingIntentHandler.setGetCredentialResponse(intent, DigitalCredential(response.responseJson))` call.
299-
IntentHelper.setGetCredentialResponse(
300-
resultData,
301-
com.google.android.gms.identitycredentials.GetCredentialResponse(
302-
Credential(
303-
DigitalCredential.TYPE_DIGITAL_CREDENTIAL,
304-
Bundle().apply {
305-
putByteArray("identityToken", response.responseJsonLegacy.toByteArray())
306-
}
307-
)
308-
)
309-
)
310292
PendingIntentHandler.setGetCredentialResponse(
311293
resultData,
312-
GetCredentialResponse(DigitalCredential(response.responseJsonModern))
294+
GetCredentialResponse(DigitalCredential(response.responseJson))
313295
)
314296

315297
setResult(RESULT_OK, resultData)
@@ -355,11 +337,9 @@ class GetCredentialActivity : FragmentActivity() {
355337
}
356338

357339
data class DigitalCredentialResult(
358-
// New integration should no longer need this legacy setup
359-
val responseJsonLegacy: String,
360340
val authenticationTitle: CharSequence,
361341
val authenticationSubtitle: CharSequence?,
362-
val responseJsonModern: String, // Now we need to include the full DigitalCredential (i.e. {"protocol": ..., "data": ...}
342+
val responseJson: String,
363343
)
364344

365345
sealed class DigitalCredentialRequestOptions {

app/src/main/java/com/credman/cmwallet/pnv/PnvTokenRegistry.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import com.credman.cmwallet.pnv.PnvTokenRegistry.Companion.VCT_GET_PHONE_NUMBER
2727
import com.credman.cmwallet.pnv.PnvTokenRegistry.Companion.VCT_VERIFY_PHONE_NUMBER
2828
import com.credman.cmwallet.toBase64UrlNoPadding
2929
import com.credman.cmwallet.toJWK
30-
import io.ktor.util.encodeBase64
3130
import kotlinx.serialization.json.add
3231
import kotlinx.serialization.json.buildJsonArray
3332
import kotlinx.serialization.json.buildJsonObject
@@ -43,7 +42,6 @@ import java.security.KeyStore
4342
import java.security.MessageDigest
4443
import java.security.interfaces.ECPrivateKey
4544
import java.time.Instant
46-
import java.util.Enumeration
4745

4846
/**
4947
* A phone number verification entry to be registered with the Credential Manager.
@@ -408,10 +406,9 @@ fun maybeHandlePnv(
408406
Log.d(PNV_TAG, "Returning $response")
409407

410408
return DigitalCredentialResult(
411-
responseJsonLegacy = "",
412409
authenticationTitle = "",
413410
authenticationSubtitle = null,
414-
responseJsonModern = JSONObject().apply {
411+
responseJson = JSONObject().apply {
415412
put("protocol", openId4VPRequest.protocolIdentifier)
416413
put("data", JSONObject(response))
417414
}.toString()

0 commit comments

Comments
 (0)