Skip to content

Commit

Permalink
Merge pull request #75 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 1, 2024
2 parents baef96d + be207bf commit 4b419ff
Show file tree
Hide file tree
Showing 70 changed files with 1,405 additions and 317 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/android-sdk-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: WalletAndroid-SDK-Tests

on:
pull_request:
branches:
- main
- rc
- dev
env:
PACKAGE_TYPE: "aar"
GRADLE_VERSION: "7.5"
JAVA_VERSION: "17"
ARTIFACT_PATH: "VCL/build/outputs"
ANDROID_NEXUS_SIGNING_KEY_ID: ${{ secrets.ANDROID_NEXUS_SIGNING_KEY_ID }}
ANDROID_NEXUS_SIGNING_PWD: ${{ secrets.ANDROID_NEXUS_SIGNING_PWD }}
ANDROID_NEXUS_OSSRH_USERNAME: ${{ secrets.ANDROID_NEXUS_OSSRH_USERNAME }}
ANDROID_NEXUS_OSSRH_PWD: ${{ secrets.ANDROID_NEXUS_OSSRH_PWD }}
ANDROID_NEXUS_STAGING_PROFILE_ID: ${{ secrets.ANDROID_NEXUS_STAGING_PROFILE_ID }}
ANDROID_NEXUS_PRIVATE_KEY: ${{ secrets.ANDROID_NEXUS_PRIVATE_KEY }}
jobs:
test-android-sdk:
runs-on: ubuntu-latest
steps:
- name: Git clone repository
uses: actions/checkout@v4
# Setup java
- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: ${{ env.JAVA_VERSION }}
# Run test
- name: Run Test
run: ./gradlew test
83 changes: 83 additions & 0 deletions .github/workflows/android-sdk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: WalletAndroid-SDK

on:
push:
branches:
- main
- rc
- dev
env:
PACKAGE_TYPE: "aar"
GRADLE_VERSION: "7.5"
JAVA_VERSION: "17"
ARTIFACT_PATH: "VCL/build/outputs"
ANDROID_NEXUS_SIGNING_KEY_ID: ${{ secrets.ANDROID_NEXUS_SIGNING_KEY_ID }}
ANDROID_NEXUS_SIGNING_PWD: ${{ secrets.ANDROID_NEXUS_SIGNING_PWD }}
ANDROID_NEXUS_OSSRH_USERNAME: ${{ secrets.ANDROID_NEXUS_OSSRH_USERNAME }}
ANDROID_NEXUS_OSSRH_PWD: ${{ secrets.ANDROID_NEXUS_OSSRH_PWD }}
ANDROID_NEXUS_STAGING_PROFILE_ID: ${{ secrets.ANDROID_NEXUS_STAGING_PROFILE_ID }}
ANDROID_NEXUS_PRIVATE_KEY: ${{ secrets.ANDROID_NEXUS_PRIVATE_KEY }}
jobs:
test-android-sdk:
runs-on: ubuntu-latest
steps:
- name: Git clone repository
uses: actions/checkout@v4
# Setup java
- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: ${{ env.JAVA_VERSION }}
# Run test
- name: Run Test
run: ./gradlew test

build-android-sdk:
runs-on: ubuntu-latest
needs:
- test-android-sdk
steps:
- name: Git clone repository
uses: actions/checkout@v4
# Setup java
- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: ${{ env.JAVA_VERSION }}
# Gradle Assemble
- name: Gradle Assemble
run: ./gradlew assemble${{ env.RELEASE_TAG }}
env:
RELEASE_TAG: ${{ github.ref == 'refs/heads/main' && format('{0}', 'Release' ) || 'Rc' }}
# Convert artifact to lowercase
- name: Rename artifact to lowercase
run: mv ${{ env.ARTIFACT_PATH}}/${{ env.PACKAGE_TYPE }}/VCL-${{ env.RELEASE_TAG }}.${{ env.PACKAGE_TYPE }} ${{ env.ARTIFACT_PATH }}/${{ env.PACKAGE_TYPE }}/vcl-${{ env.RELEASE_TAG }}.${{ env.PACKAGE_TYPE }}
env:
RELEASE_TAG: ${{ github.ref == 'refs/heads/main' && format('{0}', 'release' ) || 'rc' }}
# Show Me Builded packages
- name: Show Me Builded packages
run: ls -al ${{ env.ARTIFACT_PATH}}/${{ env.PACKAGE_TYPE }}/
# Publish Main/Rc
- name: Publish Main/Rc
if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/rc' }}
run: ./gradlew publish${{ env.RELEASE_TAG }}
env:
RELEASE_TAG: ${{ github.ref == 'refs/heads/main' && format('{0}', 'Release' ) || 'Rc' }}
# Upload Artifacts
- name: Upload Artifact
if: success()
uses: actions/upload-artifact@v3
with:
name: vcl-${{ env.RELEASE_TAG }}.${{ env.PACKAGE_TYPE }}
path: ${{ env.ARTIFACT_PATH }}/${{ env.PACKAGE_TYPE }}
if-no-files-found: error
retention-days: 1
env:
RELEASE_TAG: ${{ github.ref == 'refs/heads/main' && format('{0}', 'release' ) || 'rc' }}







76 changes: 65 additions & 11 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.20.1"
versionCode 115
versionName "1.23.0"
versionCode 119
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}
Expand All @@ -41,6 +41,13 @@ android {
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
rc {
buildConfigField "String", "VERSION_NAME", "\"${defaultConfig.versionName}-rc\""
buildConfigField "int", "VERSION_CODE", "${defaultConfig.versionCode}"
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

compileOptions {
Expand Down Expand Up @@ -96,6 +103,54 @@ artifacts {
afterEvaluate {
publishing {
publications {
rc(MavenPublication) {
groupId getGroupId()
artifactId getArtifactId()

// define rc version name
def vers = getVersionName()
def rcSuffix = rootProject.ext.rcSuffix
version = "${vers}-${rcSuffix}"

// Two artifacts, the `aar` (or `jar`) and the sources
if (project.plugins.findPlugin("com.android.library")) {
from components.release
} else {
from components.java
}

artifact androidSourcesJar

// Mostly self-explanatory metadata
pom {
name = getArtifactId()
// Library description
description = 'Velocity Career Labs Android library'
// Library Github URL
url = 'https://github.com/velocitycareerlabs/WalletAndroid'
licenses {
license {
name = 'Apache License 2.0'
// Library license
url = 'https://github.com/velocitycareerlabs/WalletAndroid/blob/dev/VCL/LICENSE'
}
}
developers {
developer {
id = 'velocitycareerlabs'
name = 'Michael Avoyan'
email = '[email protected]'
}
}

scm {
// Library info on Github
connection = 'scm:github.com/velocitycareerlabs/WalletAndroid.git'
developerConnection = 'scm:git:ssh://github.com/velocitycareerlabs/WalletAndroid.git'
url = 'https://github.com/velocitycareerlabs/WalletAndroid'
}
}
}
release(MavenPublication) {
groupId getGroupId()
artifactId getArtifactId()
Expand Down Expand Up @@ -142,15 +197,14 @@ afterEvaluate {
}
}
}
}

signing {
useInMemoryPgpKeys(
rootProject.ext.signingKeyId,
rootProject.ext.signingPrivateKey,
rootProject.ext.signingPassword,
)
sign publishing.publications
signing {
useInMemoryPgpKeys(
rootProject.ext.signingKeyId,
rootProject.ext.signingPrivateKey,
rootProject.ext.signingPassword,
)
sign publishing.publications
}
}

repositories {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,47 @@

package io.velocitycareerlabs.api.entities

import io.velocitycareerlabs.impl.extensions.getUrlSubPath
import kotlin.io.path.ExperimentalPathApi

data class VCLCredentialManifest(
val jwt: VCLJwt,
val vendorOriginContext: String? = null,
val verifiedProfile: VCLVerifiedProfile
val verifiedProfile: VCLVerifiedProfile,
val deepLink: VCLDeepLink? = null
) {
val iss: String get() = jwt.payload?.toJSONObject()?.get(KeyIss) as? String ?: ""
val did: String get() = iss
val issuerId: String get() = retrieveIssuerId()
val aud: String get() = retrieveAud()
val issuerId: String get() = jwt.payload?.toJSONObject()?.get(CodingKeys.KeyIssuer) as? String
?: (jwt.payload?.toJSONObject()?.get(CodingKeys.KeyIssuer) as? Map<*, *>)?.get(CodingKeys.KeyId) as? String
?: ""
val exchangeId: String get() = jwt.payload?.toJSONObject()?.get(KeyExchangeId) as? String ?: ""
val presentationDefinitionId: String get() = (jwt.payload?.toJSONObject()?.get(KeyPresentationDefinitionId) as? Map<*, *>)?.get(
KeyId) as? String ?: ""

val finalizeOffersUri: String get() =
(jwt.payload?.toJSONObject()?.get(VCLCredentialManifest.KeyMetadata) as? Map<*, *>)?.get(
VCLCredentialManifest.KeyFinalizeOffersUri
)?.toString() ?: ""

val checkOffersUri: String get() =
(jwt.payload?.toJSONObject()?.get(VCLCredentialManifest.KeyMetadata) as? Map<*, *>)?.get(
VCLCredentialManifest.KeyCheckOffersUri
)?.toString() ?: ""

val submitPresentationUri: String get() =
(jwt.payload?.toJSONObject()?.get(VCLCredentialManifest.KeyMetadata) as? Map<*, *>)?.get(
VCLCredentialManifest.KeySubmitIdentificationUri
)?.toString() ?: ""

@OptIn(ExperimentalStdlibApi::class)
private fun retrieveIssuerId() =
((jwt.payload?.toJSONObject()?.getOrDefault(CodingKeys.KeyMetadata, HashMap<String, Any>()) as? Map<String, Any> )?.getOrDefault(CodingKeys.KeyFinalizeOffersUri, "") as? String ?: "").substringBefore("/issue/")
val presentationDefinitionId: String
get() = (jwt.payload?.toJSONObject()?.get(KeyPresentationDefinitionId) as? Map<*, *>)?.get(
KeyId
) as? String ?: ""

val finalizeOffersUri: String
get() =
(jwt.payload?.toJSONObject()
?.get(VCLCredentialManifest.KeyMetadata) as? Map<*, *>)?.get(
VCLCredentialManifest.KeyFinalizeOffersUri
)?.toString() ?: ""

val checkOffersUri: String
get() =
(jwt.payload?.toJSONObject()
?.get(VCLCredentialManifest.KeyMetadata) as? Map<*, *>)?.get(
VCLCredentialManifest.KeyCheckOffersUri
)?.toString() ?: ""

val submitPresentationUri: String
get() =
(jwt.payload?.toJSONObject()
?.get(VCLCredentialManifest.KeyMetadata) as? Map<*, *>)?.get(
VCLCredentialManifest.KeySubmitIdentificationUri
)?.toString() ?: ""

private fun retrieveAud() =
((jwt.payload?.toJSONObject()?.getOrDefault(CodingKeys.KeyMetadata, HashMap<String, Any>()) as? Map<String, Any> )?.getOrDefault(CodingKeys.KeyFinalizeOffersUri, "") as? String ?: "").substringBefore("/issue/")
companion object CodingKeys {
const val KeyIssuingRequest = "issuing_request"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ open class VCLCredentialManifestDescriptor(
val issuingType: VCLIssuingType = VCLIssuingType.Career,
val credentialTypes: List<String>? = null,
val pushDelegate: VCLPushDelegate? = null,
val vendorOriginContext: String? = null
val vendorOriginContext: String? = null,
val deepLink: VCLDeepLink? = null
) {
val did = uri?.getUrlSubPath(KeyDidPrefix)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ package io.velocitycareerlabs.api.entities
class VCLCredentialManifestDescriptorByDeepLink(
deepLink: VCLDeepLink,
issuingType: VCLIssuingType = VCLIssuingType.Career,
pushDelegate: VCLPushDelegate? = null
): VCLCredentialManifestDescriptor(
uri = deepLink.requestUri,
issuingType = issuingType,
vendorOriginContext = deepLink.vendorOriginContext
pushDelegate = pushDelegate,
vendorOriginContext = deepLink.vendorOriginContext,
deepLink = deepLink
)
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* Copyright 2022 Velocity Career Labs inc.
* SPDX-License-Identifier: Apache-2.0
*/

package io.velocitycareerlabs.api.entities

import io.velocitycareerlabs.impl.extensions.toJsonArray
Expand All @@ -22,8 +21,8 @@ data class VCLFinalizeOffersDescriptor(
.putOpt(KeyApprovedOfferIds, approvedOfferIds.toJsonArray())
.putOpt(KeyRejectedOfferIds, rejectedOfferIds.toJsonArray())

val did: String get() = credentialManifest.did
val issuerId: String get() = credentialManifest.issuerId
val aud: String get() = credentialManifest.aud
val exchangeId: String get() = credentialManifest.exchangeId
val finalizeOffersUri: String get() = credentialManifest.finalizeOffersUri
val serviceTypes: VCLServiceTypes get() = credentialManifest.verifiedProfile.serviceTypes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ data class VCLGenerateOffersDescriptor(
.putOpt(KeyTypes,types?.toJsonArray())
.putOpt(KeyOfferHashes,offerHashes?.toJsonArray())

val did: String get() = credentialManifest.did
val issuerId: String get() = credentialManifest.issuerId
val exchangeId: String get() = credentialManifest.exchangeId

val checkOffersUri: String get() = credentialManifest.checkOffersUri

companion object CodingKeys {
Expand Down
22 changes: 22 additions & 0 deletions VCL/src/main/java/io/velocitycareerlabs/api/entities/VCLOffer.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* Created by Michael Avoyan on 10/12/2023.
*
* Copyright 2022 Velocity Career Labs inc.
* SPDX-License-Identifier: Apache-2.0
*/
package io.velocitycareerlabs.api.entities

import org.json.JSONObject

data class VCLOffer(val payload: JSONObject) {
val issuerId: String get() = payload.optJSONObject(CodingKeys.KeyIssuer)?.optString(KeyId)
?: payload.optString(CodingKeys.KeyIssuer)
?: ""
val id: String get() = payload.optString(CodingKeys.KeyId) ?: ""

companion object CodingKeys {
const val KeyId = "id"
const val KeyDid = "did"
const val KeyIssuer = "issuer"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import org.json.JSONObject

data class VCLOffers (
val payload: JSONObject,
val all: JSONArray,
val all: List<VCLOffer>,
val responseCode: Int,
val sessionToken: VCLToken,
val challenge: String,
Expand Down
Loading

0 comments on commit 4b419ff

Please sign in to comment.