Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev to rc #78

Merged
merged 2 commits into from
Jan 4, 2024
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
8 changes: 4 additions & 4 deletions VCL/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ android {
defaultConfig {
minSdk 24
targetSdk 33
versionName "1.23.0"
versionCode 119
versionName "1.23.1"
versionCode 120
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}
Expand Down Expand Up @@ -217,9 +217,9 @@ repositories {
dependencies {
implementation 'androidx.core:core-ktx:1.9.0'

implementation "com.nimbusds:nimbus-jose-jwt:9.35"
implementation "com.nimbusds:nimbus-jose-jwt:9.37"
//noinspection GradleDependency
implementation "androidx.security:security-crypto:1.0.0-rc03"
implementation "androidx.security:security-crypto:1.0.0"

// Reflection
// implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,34 @@

package io.velocitycareerlabs.api.entities

import io.velocitycareerlabs.impl.extensions.appendQueryParams
import io.velocitycareerlabs.impl.extensions.encode
import io.velocitycareerlabs.impl.extensions.getUrlSubPath

open class VCLCredentialManifestDescriptor(
abstract class VCLCredentialManifestDescriptor(
val uri: String? = null,
val issuingType: VCLIssuingType = VCLIssuingType.Career,
val credentialTypes: List<String>? = null,
val pushDelegate: VCLPushDelegate? = null,
val vendorOriginContext: String? = null,
val deepLink: VCLDeepLink? = null
) {
open val endpoint = generateQueryParams()?.let { queryParams ->
uri?.appendQueryParams(queryParams)
} ?: uri

val did = uri?.getUrlSubPath(KeyDidPrefix)

private fun generateQueryParams(): String? {
val pCredentialTypes = credentialTypes?.let { credTypes ->
credTypes.map { it.encode() }.joinToString(separator = "&") { "$KeyCredentialTypes=$it" } }
val pPushDelegate = pushDelegate?.let {
"$KeyPushDelegatePushUrl=${it.pushUrl.encode()}&" + "$KeyPushDelegatePushToken=${it.pushToken}"
}
val qParams = listOfNotNull(pCredentialTypes, pPushDelegate).filter { it.isNotBlank() }
return if(qParams.isNotEmpty()) qParams.joinToString("&") else null
}

open fun toPropsString() =
StringBuilder()
.append("\nuri: , $uri")
Expand All @@ -29,8 +45,6 @@ open class VCLCredentialManifestDescriptor(
.append("\nvendorOriginContext: , $vendorOriginContext")
.toString()

open val endpoint: String? get() = uri

companion object CodingKeys {
const val KeyId = "id"
const val KeyDidPrefix = "did:"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,4 @@ class VCLCredentialManifestDescriptorByService(
StringBuilder(super.toPropsString())
.append("\nservice: ${service.toPropsString()}")
.toString()

override val endpoint = generateQueryParams()?.let { queryParams ->
uri?.appendQueryParams(queryParams)
} ?: uri

private fun generateQueryParams(): String? {
val pCredentialTypes = credentialTypes?.let { credTypes ->
credTypes.map { it.encode() }.joinToString(separator = "&") { "$KeyCredentialTypes=$it" } }
val pPushDelegate = pushDelegate?.let {
"$KeyPushDelegatePushUrl=${it.pushUrl.encode()}&" + "$KeyPushDelegatePushToken=${it.pushToken}"
}
val qParams = listOfNotNull(pCredentialTypes, pPushDelegate).filter { it.isNotBlank() }
return if(qParams.isNotEmpty()) qParams.joinToString("&") else null
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,17 @@ internal class VCLCredentialManifestDescriptorByDeepLinkTest {
subject = VCLCredentialManifestDescriptorByDeepLink(
deepLink = CredentialManifestDescriptorMocks.DeepLink,
issuingType = VCLIssuingType.Career,
pushDelegate = VCLPushDelegate(pushUrl = "some url", pushToken = "some token")
pushDelegate = VCLPushDelegate(pushUrl = "some_url", pushToken = "some_token")
)

assert(
subject.endpoint?.decode()
?.isUrlEquivalentTo(CredentialManifestDescriptorMocks.DeepLinkRequestUri.decode()) == true
subject.endpoint?.decode()?.isUrlEquivalentTo(
CredentialManifestDescriptorMocks.DeepLinkRequestUri.decode() + "&push_delegate.push_url=some_url&push_delegate.push_token=some_token"
) == true
)
assert(subject.did == CredentialManifestDescriptorMocks.IssuerDid)
assert(subject.pushDelegate?.pushUrl == "some url")
assert(subject.pushDelegate?.pushToken == "some token")
assert(subject.pushDelegate?.pushUrl == "some_url")
assert(subject.pushDelegate?.pushToken == "some_token")
}

@After
Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ dependencies {
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
// Must: be added:
implementation "com.nimbusds:nimbus-jose-jwt:9.35"
implementation "com.nimbusds:nimbus-jose-jwt:9.37"
implementation project(':VCL')

// implementation "io.velocitycareerlabs:vcl:x.y.z"
Expand Down
Loading