Skip to content

Commit

Permalink
sdk v2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelavoyan committed Feb 5, 2024
1 parent 95b7f10 commit 8d6e6e1
Show file tree
Hide file tree
Showing 29 changed files with 122 additions and 135 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 "1.23.4"
versionCode 124
versionName "2.0.0"
versionCode 125
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}
Expand Down
8 changes: 0 additions & 8 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? = null,
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? = null,
remoteCryptoServicesToken: VCLToken? = null,
successHandler: (VCLOffers) -> Unit,
errorHandler: (VCLError) -> Unit
)
Expand All @@ -75,9 +69,7 @@ interface VCL {

fun finalizeOffers(
finalizeOffersDescriptor: VCLFinalizeOffersDescriptor,
didJwk: VCLDidJwk? = null,
sessionToken: VCLToken,
remoteCryptoServicesToken: VCLToken? = null,
successHandler: (VCLJwtVerifiableCredentials) -> 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? = null,
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? = null,
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? = null,
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? = null,
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? = null,
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 @@ -9,11 +9,13 @@ package io.velocitycareerlabs.api.entities

class VCLIdentificationSubmission(
credentialManifest: VCLCredentialManifest,
verifiableCredentials: List<VCLVerifiableCredential>? = null
verifiableCredentials: List<VCLVerifiableCredential>? = null,
) : VCLSubmission(
submitUri = credentialManifest.submitPresentationUri,
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? = null,
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? = null,
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 @@ -9,14 +9,16 @@ package io.velocitycareerlabs.api.entities

class VCLPresentationSubmission(
presentationRequest: VCLPresentationRequest,
verifiableCredentials: List<VCLVerifiableCredential>
verifiableCredentials: List<VCLVerifiableCredential>,
) : VCLSubmission(
submitUri = presentationRequest.submitPresentationUri,
exchangeId = presentationRequest.exchangeId,
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? = null,
val remoteCryptoServicesToken: VCLToken? = null
) {
val jti = UUID.randomUUID().toString()
val submissionId = UUID.randomUUID().toString()
Expand Down
26 changes: 5 additions & 21 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
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
Loading

0 comments on commit 8d6e6e1

Please sign in to comment.