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

Bundle platform-verifier #1039

Merged
merged 1 commit into from
Sep 20, 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
14 changes: 13 additions & 1 deletion crates/bitwarden-uniffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#[derive(uniffi::Object)]
pub struct Client(bitwarden::Client);

#[uniffi::export]
#[uniffi::export(async_runtime = "tokio")]

Check warning on line 31 in crates/bitwarden-uniffi/src/lib.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-uniffi/src/lib.rs#L31

Added line #L31 was not covered by tests
impl Client {
/// Initialize a new instance of the SDK client
#[uniffi::constructor]
Expand Down Expand Up @@ -79,6 +79,18 @@
pub fn echo(&self, msg: String) -> String {
msg
}

/// Test method, calls http endpoint
pub async fn http_get(&self, url: String) -> Result<String> {
let client = self.0.internal.get_http_client();
let res = client
.get(&url)
.send()
.await
.map_err(bitwarden::Error::Reqwest)?;

Check warning on line 90 in crates/bitwarden-uniffi/src/lib.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-uniffi/src/lib.rs#L84-L90

Added lines #L84 - L90 were not covered by tests

Ok(res.text().await.map_err(bitwarden::Error::Reqwest)?)
}

Check warning on line 93 in crates/bitwarden-uniffi/src/lib.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-uniffi/src/lib.rs#L92-L93

Added lines #L92 - L93 were not covered by tests
}

fn init_logger() {
Expand Down
39 changes: 29 additions & 10 deletions languages/kotlin/sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ android {
minSdk 28
targetSdk 34

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
consumerProguardFiles 'consumer-rules.pro'
}

buildTypes {
Expand All @@ -31,7 +31,7 @@ android {
}

lint {
baseline = file("lint-baseline.xml")
baseline = file('lint-baseline.xml')
}

publishing {
Expand All @@ -52,9 +52,9 @@ publishing {
// PRs: use the branch name.
// Main: Grab it from `crates/bitwarden/Cargo.toml`

def branchName = "git branch --show-current".execute().text.trim()
def branchName = 'git branch --show-current'.execute().text.trim()

if (branchName == "main") {
if (branchName == 'main') {
def content = ['grep', '-o', '^version = ".*"', '../../Cargo.toml'].execute().text.trim()
def match = ~/version = "(.*)"/
def matcher = match.matcher(content)
Expand All @@ -73,19 +73,38 @@ publishing {
}
repositories {
maven {
name = "GitHubPackages"
url = "https://maven.pkg.github.com/bitwarden/sdk"
name = 'GitHubPackages'
url = 'https://maven.pkg.github.com/bitwarden/sdk'
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
username = System.getenv('GITHUB_ACTOR')
password = System.getenv('GITHUB_TOKEN')
}
}
}
}

// Find and include the classes.jar from platform-verifier.
//
// Based on the instructions from the readme in https://github.com/rustls/rustls-platform-verifier
// and issue details from https://github.com/rustls/rustls-platform-verifier/issues/115.
File findRustlsPlatformVerifierClassesJar() {
def dependencyText = providers.exec {
it.workingDir = new File('../../')
commandLine('cargo', 'metadata', '--format-version', '1', '--manifest-path', 'crates/bitwarden-uniffi/Cargo.toml')
}.standardOutput.asText.get()

def dependencyJson = new groovy.json.JsonSlurper().parseText(dependencyText)
def manifestPath = file(dependencyJson.packages.find { it.name == "rustls-platform-verifier-android" }.manifest_path)

def aar = fileTree(manifestPath.parentFile).matching {
include "maven/rustls/rustls-platform-verifier/*/rustls-platform-verifier-*.aar"
}.getSingleFile()
return zipTree(aar).matching { include 'classes.jar'}.getSingleFile()
}

Hinton marked this conversation as resolved.
Show resolved Hide resolved
dependencies {
implementation 'net.java.dev.jna:jna:5.14.0@aar'
implementation 'rustls:rustls-platform-verifier:latest.release'
implementation files(findRustlsPlatformVerifierClassesJar())

implementation 'androidx.core:core-ktx:1.13.0'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3'
Expand Down
18 changes: 1 addition & 17 deletions languages/kotlin/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,9 @@ dependencyResolutionManagement {
repositories {
google()
mavenCentral()

maven {
url = findRustlsPlatformVerifierProject()
metadataSources.artifact()
}
}
}

String findRustlsPlatformVerifierProject() {
def dependencyText = providers.exec {
it.workingDir = new File("../../")
commandLine("cargo", "metadata", "--format-version", "1", "--manifest-path", "crates/bitwarden-uniffi/Cargo.toml")
}.standardOutput.asText.get()

def dependencyJson = new groovy.json.JsonSlurper().parseText(dependencyText)
def manifestPath = file(dependencyJson.packages.find { it.name == "rustls-platform-verifier-android" }.manifest_path)
return new File(manifestPath.parentFile, "maven").path
}

rootProject.name = "My Application"
rootProject.name = 'My Application'
include ':app'
include ':sdk'
Loading