Skip to content

Commit

Permalink
Merge pull request #88 from velocitycareerlabs/VL-7087-sdk-v2.1.0
Browse files Browse the repository at this point in the history
sdk v2.1.0
  • Loading branch information
michaelavoyan authored Feb 7, 2024
2 parents 190095f + 3887f79 commit dcfe79f
Show file tree
Hide file tree
Showing 62 changed files with 376 additions and 380 deletions.
4 changes: 2 additions & 2 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 "2.0.0"
versionCode 125
versionName "2.1.0"
versionCode 126
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}
Expand Down
10 changes: 1 addition & 9 deletions VCL/src/main/java/io/velocitycareerlabs/api/VCL.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,12 @@ interface VCL {

fun getPresentationRequest(
presentationRequestDescriptor: VCLPresentationRequestDescriptor,
remoteCryptoServicesToken: VCLToken? = null,
successHandler: (VCLPresentationRequest) -> Unit,
errorHandler: (VCLError) -> Unit
)

fun submitPresentation(
presentationSubmission: VCLPresentationSubmission,
didJwk: VCLDidJwk,
remoteCryptoServicesToken: VCLToken? = null,
successHandler: (VCLSubmissionResult) -> Unit,
errorHandler: (VCLError) -> Unit
)
Expand All @@ -53,15 +50,12 @@ interface VCL {

fun getCredentialManifest(
credentialManifestDescriptor: VCLCredentialManifestDescriptor,
remoteCryptoServicesToken: VCLToken? = null,
successHandler: (VCLCredentialManifest) -> Unit,
errorHandler: (VCLError) -> Unit
)

fun generateOffers(
generateOffersDescriptor: VCLGenerateOffersDescriptor,
didJwk: VCLDidJwk,
remoteCryptoServicesToken: VCLToken? = null,
successHandler: (VCLOffers) -> Unit,
errorHandler: (VCLError) -> Unit
)
Expand All @@ -75,9 +69,7 @@ interface VCL {

fun finalizeOffers(
finalizeOffersDescriptor: VCLFinalizeOffersDescriptor,
didJwk: VCLDidJwk,
sessionToken: VCLToken,
remoteCryptoServicesToken: VCLToken? = null,
successHandler: (VCLJwtVerifiableCredentials) -> Unit,
errorHandler: (VCLError) -> Unit
)
Expand All @@ -103,8 +95,8 @@ interface VCL {
)

fun generateSignedJwt(
didJwk: VCLDidJwk,
jwtDescriptor: VCLJwtDescriptor,
didJwk: VCLDidJwk,
remoteCryptoServicesToken: VCLToken? = null,
successHandler: (VCLJwt) -> Unit,
errorHandler: (VCLError) -> Unit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ data class VCLCredentialManifest(
val jwt: VCLJwt,
val vendorOriginContext: String? = null,
val verifiedProfile: VCLVerifiedProfile,
val deepLink: VCLDeepLink? = null
val deepLink: VCLDeepLink? = null,
val didJwk: VCLDidJwk,
val remoteCryptoServicesToken: VCLToken? = null
) {
val iss: String get() = jwt.payload?.toJSONObject()?.get(KeyIss) as? String ?: ""
val did: String get() = iss
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ abstract class VCLCredentialManifestDescriptor(
val credentialTypes: List<String>? = null,
val pushDelegate: VCLPushDelegate? = null,
val vendorOriginContext: String? = null,
val deepLink: VCLDeepLink? = null
val deepLink: VCLDeepLink? = null,
val didJwk: VCLDidJwk,
val remoteCryptoServicesToken: VCLToken? = null
) {
open val endpoint = generateQueryParams()?.let { queryParams ->
uri?.appendQueryParams(queryParams)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@ package io.velocitycareerlabs.api.entities
class VCLCredentialManifestDescriptorByDeepLink(
deepLink: VCLDeepLink,
issuingType: VCLIssuingType = VCLIssuingType.Career,
pushDelegate: VCLPushDelegate? = null
pushDelegate: VCLPushDelegate? = null,
didJwk: VCLDidJwk,
remoteCryptoServicesToken: VCLToken? = null
): VCLCredentialManifestDescriptor(
uri = deepLink.requestUri,
issuingType = issuingType,
pushDelegate = pushDelegate,
vendorOriginContext = deepLink.vendorOriginContext,
deepLink = deepLink
deepLink = deepLink,
didJwk = didJwk,
remoteCryptoServicesToken = remoteCryptoServicesToken
)
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@ class VCLCredentialManifestDescriptorByService(
val service: VCLService, // for log
issuingType: VCLIssuingType = VCLIssuingType.Career,
credentialTypes: List<String>? = null,
pushDelegate: VCLPushDelegate? = null
pushDelegate: VCLPushDelegate? = null,
didJwk: VCLDidJwk,
remoteCryptoServicesToken: VCLToken? = null
): VCLCredentialManifestDescriptor(
uri = service.serviceEndpoint,
issuingType = issuingType,
credentialTypes = credentialTypes,
pushDelegate = pushDelegate
pushDelegate = pushDelegate,
didJwk = didJwk,
remoteCryptoServicesToken = remoteCryptoServicesToken
) {
override fun toPropsString() =
StringBuilder(super.toPropsString())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ import java.net.URI

class VCLCredentialManifestDescriptorRefresh(
service: VCLService,
val credentialIds: List<String>
val credentialIds: List<String>,
didJwk: VCLDidJwk,
remoteCryptoServicesToken: VCLToken? = null
): VCLCredentialManifestDescriptor(
uri = service.serviceEndpoint,
issuingType = VCLIssuingType.Refresh
issuingType = VCLIssuingType.Refresh,
didJwk = didJwk,
remoteCryptoServicesToken = remoteCryptoServicesToken
) {
override val endpoint = generateQueryParams()?.let { queryParams ->
val originUri = URI(uri)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ data class VCLFinalizeOffersDescriptor(
.putOpt(KeyApprovedOfferIds, approvedOfferIds.toJsonArray())
.putOpt(KeyRejectedOfferIds, rejectedOfferIds.toJsonArray())

val didJwk: VCLDidJwk get() = credentialManifest.didJwk
val remoteCryptoServicesToken: VCLToken? get() = credentialManifest.remoteCryptoServicesToken
val issuerId: String get() = credentialManifest.issuerId
val aud: String get() = credentialManifest.aud
val exchangeId: String get() = credentialManifest.exchangeId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@ class VCLIdentificationSubmission(
exchangeId = credentialManifest.exchangeId,
presentationDefinitionId = credentialManifest.presentationDefinitionId,
verifiableCredentials = verifiableCredentials,
vendorOriginContext = credentialManifest.vendorOriginContext
vendorOriginContext = credentialManifest.vendorOriginContext,
didJwk = credentialManifest.didJwk,
remoteCryptoServicesToken = credentialManifest.remoteCryptoServicesToken
)
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ data class VCLPresentationRequest(
val jwt: VCLJwt,
val publicJwk: VCLPublicJwk,
val deepLink: VCLDeepLink,
val pushDelegate: VCLPushDelegate? = null
val pushDelegate: VCLPushDelegate? = null,
val didJwk: VCLDidJwk,
val remoteCryptoServicesToken: VCLToken? = null
) {
companion object CodingKeys {
const val KeyId = "id"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ import java.net.URI

class VCLPresentationRequestDescriptor(
val deepLink: VCLDeepLink,
val pushDelegate: VCLPushDelegate? = null
) {
val pushDelegate: VCLPushDelegate? = null,
val didJwk: VCLDidJwk,
val remoteCryptoServicesToken: VCLToken? = null
) {
val endpoint get() = generateQueryParams()?.let { queryParams ->
deepLink.requestUri?.appendQueryParams(queryParams)
} ?: deepLink.requestUri
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ class VCLPresentationSubmission(
presentationDefinitionId = presentationRequest.presentationDefinitionId,
verifiableCredentials = verifiableCredentials,
pushDelegate = presentationRequest.pushDelegate,
vendorOriginContext = presentationRequest.vendorOriginContext
vendorOriginContext = presentationRequest.vendorOriginContext,
didJwk = presentationRequest.didJwk,
remoteCryptoServicesToken = presentationRequest.remoteCryptoServicesToken
) {
val progressUri = presentationRequest.progressUri
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ abstract class VCLSubmission(
val presentationDefinitionId: String,
val verifiableCredentials: List<VCLVerifiableCredential>? = null,
val pushDelegate: VCLPushDelegate? = null,
val vendorOriginContext: String? = null
val vendorOriginContext: String? = null,
val didJwk: VCLDidJwk,
val remoteCryptoServicesToken: VCLToken? = null
) {
val jti = UUID.randomUUID().toString()
val submissionId = UUID.randomUUID().toString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import io.velocitycareerlabs.api.entities.VCLToken

interface VCLJwtSignService {
fun sign(
didJwk: VCLDidJwk,
nonce: String? = null,
jwtDescriptor: VCLJwtDescriptor,
nonce: String? = null,
didJwk: VCLDidJwk,
remoteCryptoServicesToken: VCLToken? = null,
completionBlock: (VCLResult<VCLJwt>) -> Unit
)
Expand Down
30 changes: 7 additions & 23 deletions VCL/src/main/java/io/velocitycareerlabs/impl/VCLImpl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ internal class VCLImpl: VCL {

override fun getPresentationRequest(
presentationRequestDescriptor: VCLPresentationRequestDescriptor,
remoteCryptoServicesToken: VCLToken?,
successHandler: (VCLPresentationRequest) -> Unit,
errorHandler: (VCLError) -> Unit
) {
Expand All @@ -233,8 +232,7 @@ internal class VCLImpl: VCL {
expectedServiceTypes = VCLServiceTypes(VCLServiceType.Inspector),
successHandler = { _ ->
presentationRequestUseCase.getPresentationRequest(
presentationRequestDescriptor,
remoteCryptoServicesToken
presentationRequestDescriptor
) { presentationRequestResult ->
presentationRequestResult.handleResult(
{
Expand Down Expand Up @@ -262,15 +260,11 @@ internal class VCLImpl: VCL {

override fun submitPresentation(
presentationSubmission: VCLPresentationSubmission,
didJwk: VCLDidJwk,
remoteCryptoServicesToken: VCLToken?,
successHandler: (VCLSubmissionResult) -> Unit,
errorHandler: (VCLError) -> Unit
) {
presentationSubmissionUseCase.submit(
submission = presentationSubmission,
didJwk = didJwk,
remoteCryptoServicesToken = remoteCryptoServicesToken
submission = presentationSubmission
) { presentationSubmissionResult ->
presentationSubmissionResult.handleResult(
{
Expand Down Expand Up @@ -322,7 +316,6 @@ internal class VCLImpl: VCL {

override fun getCredentialManifest(
credentialManifestDescriptor: VCLCredentialManifestDescriptor,
remoteCryptoServicesToken: VCLToken?,
successHandler: (VCLCredentialManifest) -> Unit,
errorHandler: (VCLError) -> Unit
) {
Expand All @@ -334,8 +327,7 @@ internal class VCLImpl: VCL {
successHandler = { verifiedProfile ->
credentialManifestUseCase.getCredentialManifest(
credentialManifestDescriptor,
verifiedProfile,
remoteCryptoServicesToken
verifiedProfile
) { credentialManifest ->
credentialManifest.handleResult(
{
Expand Down Expand Up @@ -363,8 +355,6 @@ internal class VCLImpl: VCL {

override fun generateOffers(
generateOffersDescriptor: VCLGenerateOffersDescriptor,
didJwk: VCLDidJwk,
remoteCryptoServicesToken: VCLToken?,
successHandler: (VCLOffers) -> Unit,
errorHandler: (VCLError) -> Unit
) {
Expand All @@ -373,9 +363,7 @@ internal class VCLImpl: VCL {
verifiableCredentials = generateOffersDescriptor.identificationVerifiableCredentials
)
identificationSubmissionUseCase.submit(
submission = identificationSubmission,
didJwk = didJwk,
remoteCryptoServicesToken = remoteCryptoServicesToken
submission = identificationSubmission
) { identificationSubmissionResult ->
identificationSubmissionResult.handleResult(
{ identificationSubmission ->
Expand Down Expand Up @@ -432,17 +420,13 @@ internal class VCLImpl: VCL {

override fun finalizeOffers(
finalizeOffersDescriptor: VCLFinalizeOffersDescriptor,
didJwk: VCLDidJwk,
sessionToken: VCLToken,
remoteCryptoServicesToken: VCLToken?,
successHandler: (VCLJwtVerifiableCredentials) -> Unit,
errorHandler: (VCLError) -> Unit
) {
finalizeOffersUseCase.finalizeOffers(
finalizeOffersDescriptor = finalizeOffersDescriptor,
didJwk = didJwk,
sessionToken = sessionToken,
remoteCryptoServicesToken = remoteCryptoServicesToken
sessionToken = sessionToken
) { jwtVerifiableCredentials ->
jwtVerifiableCredentials.handleResult(
{
Expand Down Expand Up @@ -526,15 +510,15 @@ internal class VCLImpl: VCL {
}

override fun generateSignedJwt(
didJwk: VCLDidJwk,
jwtDescriptor: VCLJwtDescriptor,
didJwk: VCLDidJwk,
remoteCryptoServicesToken: VCLToken?,
successHandler: (VCLJwt) -> Unit,
errorHandler: (VCLError) -> Unit
) {
jwtServiceUseCase.generateSignedJwt(
didJwk = didJwk,
jwtDescriptor = jwtDescriptor,
didJwk = didJwk,
remoteCryptoServicesToken = remoteCryptoServicesToken
) { jwtResult ->
jwtResult.handleResult(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,10 @@ internal class IdentificationModelImpl(

override fun submit(
identificationSubmission: VCLIdentificationSubmission,
didJwk: VCLDidJwk,
remoteCryptoServicesToken: VCLToken?,
completionBlock: (VCLResult<VCLSubmissionResult>) -> Unit
) {
identificationSubmissionUseCase.submit(
submission = identificationSubmission,
didJwk = didJwk,
remoteCryptoServicesToken = remoteCryptoServicesToken
submission = identificationSubmission
) { result ->
result.handleResult({ data = result.data?.sessionToken }, { })
completionBlock(result)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,16 @@ internal class JwtServiceRepositoryImpl(
}

override fun generateSignedJwt(
didJwk: VCLDidJwk,
nonce: String?, // nonce == challenge
jwtDescriptor: VCLJwtDescriptor,
nonce: String?, // nonce == challenge
didJwk: VCLDidJwk,
remoteCryptoServicesToken: VCLToken?,
completionBlock: (VCLResult<VCLJwt>) -> Unit
) {
jwtSignService.sign(
didJwk = didJwk,
nonce = nonce,
jwtDescriptor = jwtDescriptor,
nonce = nonce,
didJwk = didJwk,
remoteCryptoServicesToken = remoteCryptoServicesToken,
) {
completionBlock(it)
Expand Down
Loading

0 comments on commit dcfe79f

Please sign in to comment.