Skip to content

Commit eb66631

Browse files
authored
fix: upgrade gradle & libs and remove Apollo dependency (#18)
Signed-off-by: Ahmed Moussa <[email protected]>
1 parent 3ff284d commit eb66631

File tree

36 files changed

+2150
-126
lines changed

36 files changed

+2150
-126
lines changed

.github/workflows/pull-request.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ concurrency:
1111
cancel-in-progress: true
1212

1313
env:
14-
JAVA_VERSION: 11
15-
NODEJS_VERSION: 16.17.0
14+
JAVA_VERSION: 17
1615
ATALA_GITHUB_ACTOR: ${{ secrets.ATALA_GITHUB_ACTOR }}
1716
ATALA_GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }}
1817

@@ -24,7 +23,7 @@ jobs:
2423
runs-on: macos-latest
2524
steps:
2625
- name: Checkout the repo
27-
uses: actions/checkout@v3
26+
uses: actions/checkout@v4
2827
with:
2928
token: ${{ secrets.ATALA_GITHUB_TOKEN }}
3029
fetch-depth: 0
@@ -33,7 +32,7 @@ jobs:
3332
uses: gradle/wrapper-validation-action@v1
3433

3534
- name: Cache gradle
36-
uses: actions/cache@v3
35+
uses: actions/cache@v4
3736
with:
3837
path: |
3938
~/.gradle/caches

.github/workflows/release-documentation.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ defaults:
77
shell: bash
88

99
env:
10-
JAVA_VERSION: 11
11-
NODEJS_VERSION: 16.17.0
10+
JAVA_VERSION: 17
1211
ATALA_GITHUB_ACTOR: ${{ secrets.ATALA_GITHUB_ACTOR }}
1312
ATALA_GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }}
1413

@@ -23,13 +22,13 @@ jobs:
2322
runs-on: ubuntu-latest
2423
steps:
2524
- name: "Checkout the repo"
26-
uses: actions/checkout@v3
25+
uses: actions/checkout@v4
2726

2827
- name: "Validate Gradle Wrapper"
29-
uses: gradle/wrapper-validation-action@v1
28+
uses: gradle/wrapper-validation-action@v2
3029

3130
- name: "Cache gradle"
32-
uses: actions/cache@v3
31+
uses: actions/cache@v4
3332
with:
3433
path: |
3534
~/.gradle/caches

.github/workflows/release.yml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ defaults:
77
shell: bash
88

99
env:
10-
JAVA_VERSION: 11
10+
JAVA_VERSION: 17
1111
ATALA_GITHUB_ACTOR: ${{ secrets.ATALA_GITHUB_ACTOR }}
1212
ATALA_GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }}
1313
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
@@ -22,7 +22,7 @@ jobs:
2222
build:
2323
runs-on: ubuntu-latest
2424
steps:
25-
- uses: actions/checkout@v3
25+
- uses: actions/checkout@v4
2626
with:
2727
token: ${{ secrets.ATALA_GITHUB_TOKEN }}
2828
fetch-depth: 0
@@ -32,10 +32,10 @@ jobs:
3232
node-version: '>=20.8.1'
3333

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

3737
- name: "Cache Gradle"
38-
uses: actions/cache@v3
38+
uses: actions/cache@v4
3939
with:
4040
path: |
4141
~/.gradle/caches
@@ -50,13 +50,8 @@ jobs:
5050
with:
5151
java-version: ${{ env.JAVA_VERSION }}
5252
distribution: "zulu"
53-
54-
- name: Setup Node.js
55-
uses: actions/setup-node@v3
56-
with:
57-
node-version: "lts/*"
5853

59-
- uses: crazy-max/ghaction-import-gpg@v5
54+
- uses: crazy-max/ghaction-import-gpg@v6
6055
id: import_gpg
6156
with:
6257
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}

build.gradle.kts

Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension
2-
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin
31
import java.util.Base64
42

53
val publishedMavenId: String = "io.iohk.atala.prism.didcomm"
@@ -8,6 +6,8 @@ plugins {
86
id("org.jetbrains.dokka") version "1.9.10"
97
id("maven-publish")
108
id("signing")
9+
kotlin("jvm") version "1.9.22"
10+
id("com.android.library") version "8.1.4" apply false
1111
id("io.github.gradle-nexus.publish-plugin") version "2.0.0-rc-1"
1212
id("org.jlleitschuh.gradle.ktlint") version "11.6.1"
1313
}
@@ -20,11 +20,16 @@ buildscript {
2020
}
2121
dependencies {
2222
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.22")
23-
classpath("com.android.tools.build:gradle:7.2.2")
2423
classpath("org.jetbrains.dokka:dokka-base:1.9.10")
2524
}
2625
}
2726

27+
java {
28+
toolchain {
29+
languageVersion.set(JavaLanguageVersion.of(17))
30+
}
31+
}
32+
2833
group = publishedMavenId
2934

3035
allprojects {
@@ -100,30 +105,24 @@ allprojects {
100105
url.set("https://github.com/input-output-hk/atala-prism-didcomm-kmm")
101106
}
102107
}
103-
signing {
104-
val base64EncodedAsciiArmoredSigningKey: String =
105-
System.getenv("BASE64_ARMORED_GPG_SIGNING_KEY_MAVEN") ?: ""
106-
val signingKeyPassword: String =
107-
System.getenv("SIGNING_KEY_PASSWORD") ?: ""
108-
useInMemoryPgpKeys(
109-
String(
110-
Base64.getDecoder().decode(
111-
base64EncodedAsciiArmoredSigningKey.toByteArray()
108+
if (System.getenv("BASE64_ARMORED_GPG_SIGNING_KEY_MAVEN") != null) {
109+
if (System.getenv("BASE64_ARMORED_GPG_SIGNING_KEY_MAVEN").isNotBlank()) {
110+
signing {
111+
val base64EncodedAsciiArmoredSigningKey: String =
112+
System.getenv("BASE64_ARMORED_GPG_SIGNING_KEY_MAVEN") ?: ""
113+
val signingKeyPassword: String =
114+
System.getenv("SIGNING_KEY_PASSWORD") ?: ""
115+
useInMemoryPgpKeys(
116+
String(
117+
Base64.getDecoder().decode(
118+
base64EncodedAsciiArmoredSigningKey.toByteArray()
119+
)
120+
),
121+
signingKeyPassword
112122
)
113-
),
114-
signingKeyPassword
115-
)
116-
sign(this@withType)
117-
}
118-
}
119-
}
120-
repositories {
121-
maven {
122-
this.name = "GitHubPackages"
123-
this.url = uri("https://maven.pkg.github.com/input-output-hk/atala-prism-didcomm-kmm")
124-
credentials {
125-
this.username = System.getenv("ATALA_GITHUB_ACTOR")
126-
this.password = System.getenv("ATALA_GITHUB_TOKEN")
123+
sign(this@withType)
124+
}
125+
}
127126
}
128127
}
129128
}
@@ -135,10 +134,6 @@ allprojects {
135134
}
136135
}
137136

138-
rootProject.plugins.withType(NodeJsRootPlugin::class.java) {
139-
rootProject.extensions.getByType(NodeJsRootExtension::class.java).nodeVersion = "16.17.0"
140-
}
141-
142137
nexusPublishing {
143138
repositories {
144139
sonatype {

didpeer/build.gradle.kts

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,9 @@ kotlin {
9595
sourceSets {
9696
val commonMain by getting {
9797
dependencies {
98-
implementation("io.iohk.atala.prism.apollo:multibase:1.0.2")
99-
implementation("io.iohk.atala.prism.apollo:varint:1.0.2")
100-
implementation("io.iohk.atala.prism.apollo:base64:1.0.2")
101-
implementation("io.iohk.atala.prism.apollo:base58:1.0.2")
10298
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.2")
103-
implementation("com.squareup.okio:okio:3.6.0")
99+
implementation("com.squareup.okio:okio:3.7.0")
100+
implementation("com.ionspin.kotlin:bignum:0.3.9")
104101
}
105102
}
106103
val commonTest by getting {
@@ -144,11 +141,10 @@ android {
144141
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
145142
defaultConfig {
146143
minSdk = 21
147-
targetSdk = 34
148144
}
149145
compileOptions {
150-
sourceCompatibility = JavaVersion.VERSION_11
151-
targetCompatibility = JavaVersion.VERSION_11
146+
sourceCompatibility = JavaVersion.VERSION_17
147+
targetCompatibility = JavaVersion.VERSION_17
152148
}
153149
/**
154150
* Because Software Components will not be created automatically for Maven publishing from
@@ -175,8 +171,8 @@ tasks.withType<DokkaTask>().configureEach {
175171
}
176172
dokkaSourceSets {
177173
configureEach {
178-
jdkVersion.set(11)
179-
languageVersion.set("1.8.20")
174+
jdkVersion.set(17)
175+
languageVersion.set("1.9.22")
180176
apiVersion.set("2.0")
181177
includes.from(
182178
"docs/DIDPeer.md"
@@ -210,14 +206,4 @@ afterEvaluate {
210206
tasks.withType<PublishToMavenRepository> {
211207
dependsOn(tasks.withType<Sign>())
212208
}
213-
if (tasks.findByName("lintAnalyzeDebug") != null) {
214-
tasks.named("lintAnalyzeDebug") {
215-
this.enabled = false
216-
}
217-
}
218-
if (tasks.findByName("lintAnalyzeRelease") != null) {
219-
tasks.named("lintAnalyzeRelease") {
220-
this.enabled = false
221-
}
222-
}
223209
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
package io.iohk.atala.prism.didcomm.didpeer.base16
2+
3+
import com.ionspin.kotlin.bignum.integer.BigInteger
4+
import com.ionspin.kotlin.bignum.integer.Sign
5+
6+
/**
7+
* Base16 implementation
8+
*/
9+
internal object Base16 {
10+
private val base: BigInteger = BigInteger.parseString("16")
11+
12+
/**
13+
* Encode string to Base16
14+
*/
15+
fun encode(input: ByteArray, encoding: Encoding = Encoding.Standard): String {
16+
if (input.isEmpty()) {
17+
return ""
18+
}
19+
var bi = BigInteger.fromByteArray(input, Sign.POSITIVE)
20+
val sb = StringBuilder()
21+
while (bi >= base) {
22+
val mod = bi.mod(base)
23+
sb.insert(0, encoding.alphabet[mod.intValue()])
24+
bi = bi.subtract(mod).divide(base)
25+
}
26+
sb.insert(0, encoding.alphabet[bi.intValue()])
27+
// convert leading zeros.
28+
for (b in input) {
29+
if (b.compareTo(0) == 0) {
30+
sb.insert(0, encoding.alphabet[0])
31+
} else {
32+
break
33+
}
34+
}
35+
return sb.toString()
36+
}
37+
38+
/**
39+
* Decode string to Base16
40+
*/
41+
fun decode(input: String, encoding: Encoding = Encoding.Standard): ByteArray {
42+
val bytes = decodeToBigInteger(encoding.alphabet, base, input).toByteArray()
43+
val stripSignByte = bytes.size > 1 && bytes[0].compareTo(0) == 0 && bytes[1] < 0
44+
var leadingZeros = 0
45+
var i = 0
46+
while (input[i] == encoding.alphabet[0]) {
47+
leadingZeros++
48+
i++
49+
}
50+
val tmp = ByteArray(bytes.size - (if (stripSignByte) 1 else 0) + leadingZeros)
51+
bytes.copyInto(
52+
tmp, // dest
53+
0, // dest offset
54+
if (stripSignByte) 1 else 0,
55+
tmp.size - leadingZeros // can be added -1 not sure
56+
)
57+
return tmp
58+
}
59+
60+
private fun decodeToBigInteger(alphabet: String, base: BigInteger, input: String): BigInteger {
61+
var bi = BigInteger(0)
62+
for (i in input.length - 1 downTo 0) {
63+
val alphaIndex = alphabet.indexOf(input[i])
64+
if (alphaIndex == -1) {
65+
throw IllegalStateException("Illegal character " + input[i] + " at " + i)
66+
}
67+
bi = bi.add(BigInteger(alphaIndex.toLong()).multiply(base.pow(input.length - 1 - i)))
68+
}
69+
return bi
70+
}
71+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package io.iohk.atala.prism.didcomm.didpeer.base16
2+
3+
/**
4+
* Convert [ByteArray] to [CharArray]
5+
* @return [CharArray]
6+
*/
7+
fun ByteArray.asCharArray(): CharArray {
8+
val chars = CharArray(size)
9+
for (i in chars.indices) {
10+
chars[i] = get(i).toInt().toChar()
11+
}
12+
return chars
13+
}
14+
15+
/**
16+
* Encode a [ByteArray] to Base16 [String] standard
17+
*/
18+
val ByteArray.base16Encoded: String
19+
get() = Base16.encode(this)
20+
21+
/**
22+
* Decode a [ByteArray] Base16 standard encoded to [String]
23+
*/
24+
val ByteArray.base16Decoded: String
25+
get() = asCharArray().concatToString().base16Encoded
26+
27+
/**
28+
* Encode a [ByteArray] to Base16 [String] Upper
29+
*/
30+
val ByteArray.base16UpperEncoded: String
31+
get() = Base16.encode(this, Encoding.Upper)
32+
33+
/**
34+
* Decode a [ByteArray] Base16 Upper encoded to [String]
35+
*/
36+
val ByteArray.base16UpperDecoded: String
37+
get() = asCharArray().concatToString().base16UpperDecoded
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package io.iohk.atala.prism.didcomm.didpeer.base16
2+
3+
/**
4+
* Base16 encoding scheme
5+
*/
6+
sealed interface Encoding {
7+
val alphabet: String
8+
9+
/**
10+
* Base16 Standard
11+
*/
12+
data object Standard : Encoding {
13+
override val alphabet: String = "0123456789abcdef"
14+
}
15+
16+
/**
17+
* Base16 Upper
18+
*/
19+
data object Upper : Encoding {
20+
override val alphabet: String = "0123456789ABCDEF"
21+
}
22+
}

0 commit comments

Comments
 (0)