Skip to content

Commit

Permalink
Merge branch 'main' into km/pm-12400/private-key-regen
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas-Avery authored Oct 24, 2024
2 parents 98c0d0e + db648d7 commit 15b9c75
Show file tree
Hide file tree
Showing 31 changed files with 2,417 additions and 299 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/build-wasm-internal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,23 @@ jobs:
- name: Checkout repo
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1

- name: Set version (PR)
if: ${{ github.event_name == 'pull_request' }}
run: |
echo REF_NAME="${{ github.event.pull_request.head.ref }}" >> $GITHUB_ENV
echo SHA="${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV
- name: Set env variables (Branch/Tag)
if: ${{ github.event_name == 'push' }}
run: |
echo REF_NAME="${GITHUB_REF_NAME}" >> $GITHUB_ENV
echo SHA="${GITHUB_SHA}" >> $GITHUB_ENV
- name: Set version
run: |
echo SDK_VERSION="${REF_NAME} (${SHA:0:7})" >> $GITHUB_ENV
echo "SDK_VERSION=${SDK_VERSION}"
- name: Setup Node
uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4
with:
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[workspace]
resolver = "2"
members = ["crates/*"]
members = ["crates/*", "bitwarden_license/*"]

# Global settings for all crates should be defined here
[workspace.package]
Expand All @@ -27,7 +27,7 @@ bitwarden-exporters = { path = "crates/bitwarden-exporters", version = "=1.0.0"
bitwarden-fido = { path = "crates/bitwarden-fido", version = "=1.0.0" }
bitwarden-generators = { path = "crates/bitwarden-generators", version = "=1.0.0" }
bitwarden-send = { path = "crates/bitwarden-send", version = "=1.0.0" }
bitwarden-sm = { path = "crates/bitwarden-sm", version = "=1.0.0" }
bitwarden-sm = { path = "bitwarden_license/bitwarden-sm", version = "=1.0.0" }
bitwarden-vault = { path = "crates/bitwarden-vault", version = "=1.0.0" }

# External crates that are expected to maintain a consistent version across all crates
Expand Down
315 changes: 20 additions & 295 deletions LICENSE

Large diffs are not rendered by default.

674 changes: 674 additions & 0 deletions LICENSE_GPL.txt

Large diffs are not rendered by default.

295 changes: 295 additions & 0 deletions LICENSE_SDK.txt

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ edition.workspace = true
rust-version.workspace = true
homepage.workspace = true
repository.workspace = true
license-file.workspace = true
license-file = "../../LICENSE_SDK.txt"
keywords.workspace = true

[dependencies]
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
53 changes: 53 additions & 0 deletions crates/bitwarden-wasm-internal/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
use std::{env, process::Command};

fn main() {
// Use the SDK_VERSION environment variable if it is set (e.g. by CI) or get it from Git
let sdk_version = env::var("SDK_VERSION")
.or_else(|_| version_from_git_info())
.unwrap_or("unknown".to_string());

println!("cargo:rustc-env=SDK_VERSION={sdk_version}");
println!("cargo:rustc-env=CARGO_PKG_VERSION={sdk_version}");
}

fn run(args: &[&str]) -> Result<String, std::io::Error> {
use std::io::{Error, ErrorKind};
let out = Command::new(args[0]).args(&args[1..]).output()?;
if !out.status.success() {
return Err(Error::new(ErrorKind::Other, "Command not successful"));
}
Ok(String::from_utf8(out.stdout)
.map_err(|e| Error::new(ErrorKind::Other, e.to_string()))?
.trim()
.to_string())
}

/// This method reads info from Git, namely tags, branch, and revision
/// To access these values, use:
/// - `env!("GIT_EXACT_TAG")`
/// - `env!("GIT_BRANCH")`
/// - `env!("GIT_REV")`
fn version_from_git_info() -> Result<String, std::io::Error> {
// The exact tag for the current commit, can be empty when
// the current commit doesn't have an associated tag
let exact_tag = run(&["git", "describe", "--abbrev=0", "--tags", "--exact-match"]).ok();
if let Some(ref exact) = exact_tag {
println!("cargo:rustc-env=GIT_EXACT_TAG={exact}");
}

// The current branch name
let branch = run(&["git", "rev-parse", "--abbrev-ref", "HEAD"])?;
println!("cargo:rustc-env=GIT_BRANCH={branch}");

// The current git commit hash
let rev = run(&["git", "rev-parse", "HEAD"])?;
let rev_short = rev.get(..8).unwrap_or_default();
println!("cargo:rustc-env=GIT_REV={rev_short}");

// Combined version
if let Some(exact) = exact_tag {
Ok(exact)
} else {
Ok(format!("{branch} ({rev_short})"))
}
}
4 changes: 4 additions & 0 deletions crates/bitwarden-wasm-internal/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ impl BitwardenClient {
msg
}

pub fn version(&self) -> String {
env!("SDK_VERSION").to_owned()
}

pub fn throw(&self, msg: String) -> Result<(), crate::error::GenericError> {
Err(crate::error::GenericError(msg))
}
Expand Down
2 changes: 1 addition & 1 deletion languages/js/sdk-internal/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@bitwarden/sdk-internal",
"version": "0.1.0",
"license": "SEE LICENSE IN LICENSE",
"license": "GPL-3.0",
"files": [
"bitwarden_wasm_internal_bg.js",
"bitwarden_wasm_internal_bg.wasm",
Expand Down
2 changes: 2 additions & 0 deletions languages/kotlin/sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ android {
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = '1.8'
}
Expand Down
Loading

0 comments on commit 15b9c75

Please sign in to comment.