Skip to content

Commit

Permalink
chore: enhancements
Browse files Browse the repository at this point in the history
- disable all Apple platforms except for iOS
- fix gradle build files
- add todo comments
- remove extra lines in some files
- remove annotation @PrismSdkInternal as it is no longer will be used in V2.0
- fix JS external functions
Signed-off-by: Ahmed Moussa <[email protected]>
  • Loading branch information
hamada147 committed May 13, 2024
1 parent 88f733f commit cf992ce
Show file tree
Hide file tree
Showing 15 changed files with 105 additions and 109 deletions.
2 changes: 1 addition & 1 deletion authenticate-sdk/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ kotlin {
sourceSets {
val commonMain by getting {
dependencies {
implementation("com.benasher44:uuid:0.3.0") // Apollo UUID
implementation("com.benasher44:uuid:0.3.0") // TODO("use Apollo UUID")
implementation(project(":core-sdk"))
}
}
Expand Down
90 changes: 45 additions & 45 deletions core-sdk/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ kotlin {
}
if (os.isMacOsX) {
ios()
tvos()
watchos()
macosX64()
// tvos()
// watchos()
// macosX64()
if (System.getProperty("os.arch") != "x86_64") { // M1Chip
iosSimulatorArm64()
tvosSimulatorArm64()
watchosSimulatorArm64()
macosArm64()
// tvosSimulatorArm64()
// watchosSimulatorArm64()
// macosArm64()
}
}
js(IR) {
Expand Down Expand Up @@ -80,9 +80,9 @@ kotlin {
this.version = rootProject.version.toString()
this.authors = "IOG"
this.ios.deploymentTarget = "13.0"
this.osx.deploymentTarget = "12.0"
this.tvos.deploymentTarget = "13.0"
this.watchos.deploymentTarget = "8.0"
// this.osx.deploymentTarget = "12.0"
// this.tvos.deploymentTarget = "13.0"
// this.watchos.deploymentTarget = "8.0"
framework {
this.baseName = currentModuleName
}
Expand Down Expand Up @@ -135,49 +135,49 @@ kotlin {
}
}
val iosTest by getting
val tvosMain by getting {
dependencies {
implementation("io.ktor:ktor-client-darwin:2.1.3")
}
}
val tvosTest by getting
val watchosMain by getting {
dependencies {
implementation("io.ktor:ktor-client-darwin:2.1.3")
}
}
val watchosTest by getting
val macosX64Main by getting {
dependencies {
implementation("io.ktor:ktor-client-darwin:2.1.3")
}
}
val macosX64Test by getting
// val tvosMain by getting {
// dependencies {
// implementation("io.ktor:ktor-client-darwin:2.1.3")
// }
// }
// val tvosTest by getting
// val watchosMain by getting {
// dependencies {
// implementation("io.ktor:ktor-client-darwin:2.1.3")
// }
// }
// val watchosTest by getting
// val macosX64Main by getting {
// dependencies {
// implementation("io.ktor:ktor-client-darwin:2.1.3")
// }
// }
// val macosX64Test by getting
if (System.getProperty("os.arch") != "x86_64") { // M1Chip
val iosSimulatorArm64Main by getting {
this.dependsOn(iosMain)
}
val iosSimulatorArm64Test by getting {
this.dependsOn(iosTest)
}
val tvosSimulatorArm64Main by getting {
this.dependsOn(tvosMain)
}
val tvosSimulatorArm64Test by getting {
this.dependsOn(tvosTest)
}
val watchosSimulatorArm64Main by getting {
this.dependsOn(watchosMain)
}
val watchosSimulatorArm64Test by getting {
this.dependsOn(watchosTest)
}
val macosArm64Main by getting {
this.dependsOn(macosX64Main)
}
val macosArm64Test by getting {
this.dependsOn(macosX64Test)
}
// val tvosSimulatorArm64Main by getting {
// this.dependsOn(tvosMain)
// }
// val tvosSimulatorArm64Test by getting {
// this.dependsOn(tvosTest)
// }
// val watchosSimulatorArm64Main by getting {
// this.dependsOn(watchosMain)
// }
// val watchosSimulatorArm64Test by getting {
// this.dependsOn(watchosTest)
// }
// val macosArm64Main by getting {
// this.dependsOn(macosX64Main)
// }
// val macosArm64Test by getting {
// this.dependsOn(macosX64Test)
// }
}
}
all {
Expand Down
3 changes: 0 additions & 3 deletions core-sdk/core_sdk.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ Pod::Spec.new do |spec|
spec.vendored_frameworks = 'build/cocoapods/framework/wallet_core_sdk.framework'
spec.libraries = 'c++'
spec.ios.deployment_target = '13.0'
spec.osx.deployment_target = '12.0'
spec.tvos.deployment_target = '13.0'
spec.watchos.deployment_target = '8.0'


spec.pod_target_xcconfig = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ package io.iohk.atala.prism.walletcore
import io.ktor.client.HttpClient
import io.ktor.client.HttpClientConfig


internal expect fun httpClient(config: HttpClientConfig<*>.() -> Unit = {}): HttpClient
16 changes: 11 additions & 5 deletions prism-protos/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ plugins {
id("org.jetbrains.dokka")
}

repositories {
mavenCentral()
mavenLocal()
}

kotlin {
android {
publishAllLibraryVariants()
Expand All @@ -36,6 +31,9 @@ kotlin {
}
if (os.isMacOsX) {
ios()
if (System.getProperty("os.arch") != "x86_64") { // M1Chip
iosSimulatorArm64()
}
}
js(IR) {
this.moduleName = currentModuleName
Expand Down Expand Up @@ -152,6 +150,14 @@ kotlin {
val jsTest by getting
val iosMain by getting
val iosTest by getting
if (System.getProperty("os.arch") != "x86_64") { // M1Chip
val iosSimulatorArm64Main by getting {
this.dependsOn(iosMain)
}
val iosSimulatorArm64Test by getting {
this.dependsOn(iosTest)
}
}

all {
languageSettings.optIn("kotlin.js.ExperimentalJsExport")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package io.iohk.atala.prism.protos
import io.grpc.*
import io.grpc.kotlin.ClientCalls
import io.grpc.stub.MetadataUtils
import io.iohk.atala.prism.common.PrismSdkInternal
import io.ktor.utils.io.core.*
import kotlinx.coroutines.flow.Flow
import pbandk.Message
Expand All @@ -13,7 +12,6 @@ import java.io.InputStream
import java.util.*
import java.util.concurrent.TimeUnit

@PrismSdkInternal
public actual class GrpcClient actual constructor(options: GrpcOptions) : Closeable {
private val channel: ManagedChannel =
if (options.protocol == "http") {
Expand All @@ -23,7 +21,6 @@ public actual class GrpcClient actual constructor(options: GrpcOptions) : Closea
}
private val token: String? = options.token

@PrismSdkInternal
public class MessageMarshaller<T : Message>(private val companion: Message.Companion<T>) :
MethodDescriptor.Marshaller<T> {
override fun stream(value: T): InputStream =
Expand Down Expand Up @@ -158,7 +155,6 @@ public actual class GrpcClient actual constructor(options: GrpcOptions) : Closea
}
}

@PrismSdkInternal
public companion object {
public val DID_HEADER: Metadata.Key<String> =
Metadata.Key.of(DID, Metadata.ASCII_STRING_MARSHALLER)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package io.iohk.atala.prism.protos.util

import java.util.*

// TODO("Use Apollo Base64")
public actual object Base64Utils {
public actual fun encode(bytes: ByteArray): String =
Base64.getUrlEncoder().withoutPadding().encodeToString(bytes)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.iohk.atala.prism.protos

import io.iohk.atala.prism.common.PrismSdkInternal
import io.ktor.utils.io.core.Closeable
import kotlinx.coroutines.flow.Flow
import pbandk.Message
Expand All @@ -24,7 +23,6 @@ public const val DID_SIGNATURE: String = "did-signature"
public const val REQUEST_NONCE: String = "request-nonce"
public const val PRISM_AUTH_TOKEN: String = "prism-auth-token"

@PrismSdkInternal
public expect class GrpcClient(options: GrpcOptions) : Closeable {
public suspend fun <Req : Message, Resp : Message> call(
request: Req,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.iohk.atala.prism.protos.util

// TODO("Use Apollo Base64")
public expect object Base64Utils {
/**
* Returns a URL-safe Base64 encoding without padding (i.e. no trailing '='s).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import platform.Foundation.base64EncodedStringWithOptions
import platform.Foundation.create
import platform.posix.memcpy

// TODO("Use Apollo Base64")
public actual object Base64Utils {
public actual fun encode(bytes: ByteArray): String {
val nsData = memScoped {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ internal external interface Metadata {
operator fun set(s: String, value: String)
}

internal external open class AbstractClientBase {
internal open external class AbstractClientBase {
open fun <REQ, RESP> thenableCall(method: String, request: REQ, metadata: Metadata, methodDescriptor: MethodDescriptor<REQ, RESP>): Promise<RESP>
open fun <REQ, RESP> rpcCall(method: String, request: REQ, metadata: Metadata, methodDescriptor: MethodDescriptor<REQ, RESP>, callback: (err: Error, response: RESP) -> Unit): ClientReadableStream<RESP>
open fun <REQ, RESP> serverStreaming(method: String, request: REQ, metadata: Metadata, methodDescriptor: MethodDescriptor<REQ, RESP>): ClientReadableStream<RESP>
open class MethodInfo<REQ, RESP>(responseType: Any, requestSerializeFn: (request: REQ) -> Any, responseDeserializeFn: (bytes: Uint8Array) -> RESP)
}

internal external open class ClientReadableStream<RESP> {
internal open external class ClientReadableStream<RESP> {
open fun on(eventType: String /* "error" */, callback: (err: Error) -> Unit): ClientReadableStream<RESP>
open fun on(eventType: String /* "status" */, callback: (status: Status) -> Unit): ClientReadableStream<RESP>
open fun on(eventType: String /* "metadata" */, callback: (status: Metadata) -> Unit): ClientReadableStream<RESP>
Expand All @@ -53,20 +53,20 @@ internal external interface UnaryInterceptor<REQ, RESP> {
fun intercept(request: Request<REQ, RESP>, invoker: (request: Request<REQ, RESP>) -> Promise<UnaryResponse<REQ, RESP>>): Promise<UnaryResponse<REQ, RESP>>
}

internal external open class CallOptions(options: Json)
internal open external class CallOptions(options: Json)

internal external open class MethodDescriptor<REQ, RESP>(name: String, methodType: Any, requestType: Any, responseType: Any, requestSerializeFn: Any, responseDeserializeFn: Any) {
internal open external class MethodDescriptor<REQ, RESP>(name: String, methodType: Any, requestType: Any, responseType: Any, requestSerializeFn: Any, responseDeserializeFn: Any) {
open fun createRequest(requestMessage: REQ, metadata: Metadata, callOptions: CallOptions): UnaryResponse<REQ, RESP>
}

internal external open class Request<REQ, RESP> {
internal open external class Request<REQ, RESP> {
open fun getRequestMessage(): REQ
open fun getMethodDescriptor(): MethodDescriptor<REQ, RESP>
open fun getMetadata(): Metadata
open fun getCallOptions(): CallOptions
}

internal external open class UnaryResponse<REQ, RESP> {
internal open external class UnaryResponse<REQ, RESP> {
open fun getResponseMessage(): RESP
open fun getMetadata(): Metadata
open fun getMethodDescriptor(): MethodDescriptor<REQ, RESP>
Expand All @@ -82,7 +82,7 @@ internal external interface GrpcWebClientBaseOptions {
set(value) = definedExternally
}

internal external open class GrpcWebClientBase(options: GrpcWebClientBaseOptions) : AbstractClientBase
internal open external class GrpcWebClientBase(options: GrpcWebClientBaseOptions) : AbstractClientBase

internal external interface Error {
var code: Number
Expand All @@ -95,4 +95,4 @@ internal external interface Status {
var metadata: Metadata?
get() = definedExternally
set(value) = definedExternally
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.iohk.atala.prism.protos.util

// TODO("Use Apollo Base64")
public actual object Base64Utils {
// https://regexland.com/base64/
private val base64Regex = """^(?:[A-Za-z\d+/]{4})*(?:[A-Za-z\d+/]{3}=|[A-Za-z\d+/]{2}==)?$""".toRegex()
Expand Down
7 changes: 3 additions & 4 deletions protosLib/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import com.google.protobuf.gradle.id
import com.google.protobuf.gradle.proto
import com.google.protobuf.gradle.remove
@file:Suppress("ktlint:no-wildcard-imports")
import com.google.protobuf.gradle.*
import org.gradle.internal.os.OperatingSystem

val os: OperatingSystem = OperatingSystem.current()
Expand All @@ -20,7 +19,7 @@ dependencies {
jarPathConf("io.iohk.atala:pbandk-prism-clients-generator:0.20.7")

// This is needed for includes, ref: https://github.com/google/protobuf-gradle-plugin/issues/41#issuecomment-143884188
// compileOnly("com.google.protobuf:protobuf-java:3.21.9")
compileOnly("com.google.protobuf:protobuf-java:3.21.9")
}

sourceSets {
Expand Down
Loading

0 comments on commit cf992ce

Please sign in to comment.