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

fix: upgrade gradle & libs and remove Apollo dependency #18

Merged
merged 1 commit into from
Mar 6, 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
7 changes: 3 additions & 4 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ concurrency:
cancel-in-progress: true

env:
JAVA_VERSION: 11
NODEJS_VERSION: 16.17.0
JAVA_VERSION: 17
ATALA_GITHUB_ACTOR: ${{ secrets.ATALA_GITHUB_ACTOR }}
ATALA_GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }}

Expand All @@ -24,7 +23,7 @@ jobs:
runs-on: macos-latest
steps:
- name: Checkout the repo
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
token: ${{ secrets.ATALA_GITHUB_TOKEN }}
fetch-depth: 0
Expand All @@ -33,7 +32,7 @@ jobs:
uses: gradle/wrapper-validation-action@v1

- name: Cache gradle
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/release-documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ defaults:
shell: bash

env:
JAVA_VERSION: 11
NODEJS_VERSION: 16.17.0
JAVA_VERSION: 17
ATALA_GITHUB_ACTOR: ${{ secrets.ATALA_GITHUB_ACTOR }}
ATALA_GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }}

Expand All @@ -23,13 +22,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: "Checkout the repo"
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: "Validate Gradle Wrapper"
uses: gradle/wrapper-validation-action@v1
uses: gradle/wrapper-validation-action@v2

- name: "Cache gradle"
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
Expand Down
15 changes: 5 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ defaults:
shell: bash

env:
JAVA_VERSION: 11
JAVA_VERSION: 17
ATALA_GITHUB_ACTOR: ${{ secrets.ATALA_GITHUB_ACTOR }}
ATALA_GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }}
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
Expand All @@ -22,7 +22,7 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
token: ${{ secrets.ATALA_GITHUB_TOKEN }}
fetch-depth: 0
Expand All @@ -32,10 +32,10 @@ jobs:
node-version: '>=20.8.1'

- name: "Validate Gradle Wrapper"
uses: gradle/wrapper-validation-action@v1
uses: gradle/wrapper-validation-action@v2

- name: "Cache Gradle"
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
Expand All @@ -50,13 +50,8 @@ jobs:
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: "zulu"

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "lts/*"

- uses: crazy-max/ghaction-import-gpg@v5
- uses: crazy-max/ghaction-import-gpg@v6
id: import_gpg
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
Expand Down
55 changes: 25 additions & 30 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin
import java.util.Base64

val publishedMavenId: String = "io.iohk.atala.prism.didcomm"
Expand All @@ -8,6 +6,8 @@ plugins {
id("org.jetbrains.dokka") version "1.9.10"
id("maven-publish")
id("signing")
kotlin("jvm") version "1.9.22"
id("com.android.library") version "8.1.4" apply false
id("io.github.gradle-nexus.publish-plugin") version "2.0.0-rc-1"
id("org.jlleitschuh.gradle.ktlint") version "11.6.1"
}
Expand All @@ -20,11 +20,16 @@ buildscript {
}
dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.22")
classpath("com.android.tools.build:gradle:7.2.2")
classpath("org.jetbrains.dokka:dokka-base:1.9.10")
}
}

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}

group = publishedMavenId

allprojects {
Expand Down Expand Up @@ -100,30 +105,24 @@ allprojects {
url.set("https://github.com/input-output-hk/atala-prism-didcomm-kmm")
}
}
signing {
val base64EncodedAsciiArmoredSigningKey: String =
System.getenv("BASE64_ARMORED_GPG_SIGNING_KEY_MAVEN") ?: ""
val signingKeyPassword: String =
System.getenv("SIGNING_KEY_PASSWORD") ?: ""
useInMemoryPgpKeys(
String(
Base64.getDecoder().decode(
base64EncodedAsciiArmoredSigningKey.toByteArray()
if (System.getenv("BASE64_ARMORED_GPG_SIGNING_KEY_MAVEN") != null) {
if (System.getenv("BASE64_ARMORED_GPG_SIGNING_KEY_MAVEN").isNotBlank()) {
signing {
val base64EncodedAsciiArmoredSigningKey: String =
System.getenv("BASE64_ARMORED_GPG_SIGNING_KEY_MAVEN") ?: ""
val signingKeyPassword: String =
System.getenv("SIGNING_KEY_PASSWORD") ?: ""
useInMemoryPgpKeys(
String(
Base64.getDecoder().decode(
base64EncodedAsciiArmoredSigningKey.toByteArray()
)
),
signingKeyPassword
)
),
signingKeyPassword
)
sign(this@withType)
}
}
}
repositories {
maven {
this.name = "GitHubPackages"
this.url = uri("https://maven.pkg.github.com/input-output-hk/atala-prism-didcomm-kmm")
credentials {
this.username = System.getenv("ATALA_GITHUB_ACTOR")
this.password = System.getenv("ATALA_GITHUB_TOKEN")
sign(this@withType)
}
}
}
}
}
Expand All @@ -135,10 +134,6 @@ allprojects {
}
}

rootProject.plugins.withType(NodeJsRootPlugin::class.java) {
rootProject.extensions.getByType(NodeJsRootExtension::class.java).nodeVersion = "16.17.0"
}

nexusPublishing {
repositories {
sonatype {
Expand Down
26 changes: 6 additions & 20 deletions didpeer/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,9 @@ kotlin {
sourceSets {
val commonMain by getting {
dependencies {
implementation("io.iohk.atala.prism.apollo:multibase:1.0.2")
implementation("io.iohk.atala.prism.apollo:varint:1.0.2")
implementation("io.iohk.atala.prism.apollo:base64:1.0.2")
implementation("io.iohk.atala.prism.apollo:base58:1.0.2")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.2")
implementation("com.squareup.okio:okio:3.6.0")
implementation("com.squareup.okio:okio:3.7.0")
implementation("com.ionspin.kotlin:bignum:0.3.9")
}
}
val commonTest by getting {
Expand Down Expand Up @@ -144,11 +141,10 @@ android {
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
defaultConfig {
minSdk = 21
targetSdk = 34
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
/**
* Because Software Components will not be created automatically for Maven publishing from
Expand All @@ -175,8 +171,8 @@ tasks.withType<DokkaTask>().configureEach {
}
dokkaSourceSets {
configureEach {
jdkVersion.set(11)
languageVersion.set("1.8.20")
jdkVersion.set(17)
languageVersion.set("1.9.22")
apiVersion.set("2.0")
includes.from(
"docs/DIDPeer.md"
Expand Down Expand Up @@ -210,14 +206,4 @@ afterEvaluate {
tasks.withType<PublishToMavenRepository> {
dependsOn(tasks.withType<Sign>())
}
if (tasks.findByName("lintAnalyzeDebug") != null) {
tasks.named("lintAnalyzeDebug") {
this.enabled = false
}
}
if (tasks.findByName("lintAnalyzeRelease") != null) {
tasks.named("lintAnalyzeRelease") {
this.enabled = false
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package io.iohk.atala.prism.didcomm.didpeer.base16

import com.ionspin.kotlin.bignum.integer.BigInteger
import com.ionspin.kotlin.bignum.integer.Sign

/**
* Base16 implementation
*/
internal object Base16 {
private val base: BigInteger = BigInteger.parseString("16")

/**
* Encode string to Base16
*/
fun encode(input: ByteArray, encoding: Encoding = Encoding.Standard): String {
if (input.isEmpty()) {
return ""
}
var bi = BigInteger.fromByteArray(input, Sign.POSITIVE)
val sb = StringBuilder()
while (bi >= base) {
val mod = bi.mod(base)
sb.insert(0, encoding.alphabet[mod.intValue()])
bi = bi.subtract(mod).divide(base)
}
sb.insert(0, encoding.alphabet[bi.intValue()])
// convert leading zeros.
for (b in input) {
if (b.compareTo(0) == 0) {
sb.insert(0, encoding.alphabet[0])
} else {
break
}
}
return sb.toString()
}

/**
* Decode string to Base16
*/
fun decode(input: String, encoding: Encoding = Encoding.Standard): ByteArray {
val bytes = decodeToBigInteger(encoding.alphabet, base, input).toByteArray()
val stripSignByte = bytes.size > 1 && bytes[0].compareTo(0) == 0 && bytes[1] < 0
var leadingZeros = 0
var i = 0
while (input[i] == encoding.alphabet[0]) {
leadingZeros++
i++
}
val tmp = ByteArray(bytes.size - (if (stripSignByte) 1 else 0) + leadingZeros)
bytes.copyInto(
tmp, // dest
0, // dest offset
if (stripSignByte) 1 else 0,
tmp.size - leadingZeros // can be added -1 not sure
)
return tmp
}

private fun decodeToBigInteger(alphabet: String, base: BigInteger, input: String): BigInteger {
var bi = BigInteger(0)
for (i in input.length - 1 downTo 0) {
val alphaIndex = alphabet.indexOf(input[i])
if (alphaIndex == -1) {
throw IllegalStateException("Illegal character " + input[i] + " at " + i)
}
bi = bi.add(BigInteger(alphaIndex.toLong()).multiply(base.pow(input.length - 1 - i)))
}
return bi
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package io.iohk.atala.prism.didcomm.didpeer.base16

/**
* Convert [ByteArray] to [CharArray]
* @return [CharArray]
*/
fun ByteArray.asCharArray(): CharArray {
val chars = CharArray(size)
for (i in chars.indices) {
chars[i] = get(i).toInt().toChar()
}
return chars
}

/**
* Encode a [ByteArray] to Base16 [String] standard
*/
val ByteArray.base16Encoded: String
get() = Base16.encode(this)

/**
* Decode a [ByteArray] Base16 standard encoded to [String]
*/
val ByteArray.base16Decoded: String
get() = asCharArray().concatToString().base16Encoded

/**
* Encode a [ByteArray] to Base16 [String] Upper
*/
val ByteArray.base16UpperEncoded: String
get() = Base16.encode(this, Encoding.Upper)

/**
* Decode a [ByteArray] Base16 Upper encoded to [String]
*/
val ByteArray.base16UpperDecoded: String
get() = asCharArray().concatToString().base16UpperDecoded
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package io.iohk.atala.prism.didcomm.didpeer.base16

/**
* Base16 encoding scheme
*/
sealed interface Encoding {
val alphabet: String

/**
* Base16 Standard
*/
data object Standard : Encoding {
override val alphabet: String = "0123456789abcdef"
}

/**
* Base16 Upper
*/
data object Upper : Encoding {
override val alphabet: String = "0123456789ABCDEF"
}
}
Loading
Loading