Skip to content

Commit

Permalink
Merge pull request #79 from velocitycareerlabs/rc-to-main
Browse files Browse the repository at this point in the history
Rc to main
  • Loading branch information
michaelavoyan authored Jan 4, 2024
2 parents 4b419ff + 8821d23 commit 653ccfd
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 27 deletions.
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

0 comments on commit 653ccfd

Please sign in to comment.