Skip to content

Commit

Permalink
Merge branch 'main' into ps/argon2-publish
Browse files Browse the repository at this point in the history
# Conflicts:
#	crates/bitwarden-wasm/Cargo.toml
  • Loading branch information
dani-garcia committed Apr 9, 2024
2 parents db5b055 + 1ccf11b commit 92eeea5
Show file tree
Hide file tree
Showing 23 changed files with 226 additions and 127 deletions.
51 changes: 8 additions & 43 deletions .github/workflows/version-bump.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@ on:
type: choice
options:
- bitwarden
- bitwarden-api-api
- bitwarden-api-identity
- bitwarden-crypto
- bitwarden-generators
- bitwarden-json
- cli
- bws
- napi
- python-sdk
- ruby-sdk
Expand Down Expand Up @@ -45,7 +40,7 @@ jobs:
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3

- name: Install cargo-release
run: cargo install cargo-edit
run: cargo install cargo-edit --locked

- name: Login to Azure - CI Subscription
uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0
Expand Down Expand Up @@ -103,49 +98,19 @@ jobs:
- name: Bump napi crate Version
if: ${{ inputs.project == 'napi' }}
run: cargo-set-version set-version -p bitwarden-napi ${{ inputs.version_number }}
run: cargo set-version -p bitwarden-napi ${{ inputs.version_number }}

### bitwarden

- name: Bump bitwarden crate Version
if: ${{ inputs.project == 'bitwarden' }}
run: cargo-set-version set-version -p bitwarden ${{ inputs.version_number }}
run: cargo set-version -p bitwarden ${{ inputs.version_number }}

### bitwarden-api-api
### bws

- name: Bump bitwarden-api-api crate Version
if: ${{ inputs.project == 'bitwarden-api-api' }}
run: cargo-set-version set-version -p bitwarden-api-api ${{ inputs.version_number }}

### bitwarden-api-identity

- name: Bump bitwarden-api-identity crate Version
if: ${{ inputs.project == 'bitwarden-api-identity' }}
run: cargo-set-version set-version -p bitwarden-api-identity ${{ inputs.version_number }}

### bitwarden-crypto

- name: Bump bitwarden-crypto crate Version
if: ${{ inputs.project == 'bitwarden-crypto' }}
run: cargo-set-version set-version -p bitwarden-crypto ${{ inputs.version_number }}

### bitwarden-generators

- name: Bump bitwarden-generators crate Version
if: ${{ inputs.project == 'bitwarden-generators' }}
run: cargo-set-version set-version -p bitwarden-generators ${{ inputs.version_number }}

### cli

- name: Bump cli Version
if: ${{ inputs.project == 'cli' }}
run: cargo-set-version set-version -p bws ${{ inputs.version_number }}

### bitwarden-json

- name: Bump bitwarden-json crate Version
if: ${{ inputs.project == 'bitwarden-json' }}
run: cargo-set-version set-version -p bitwarden-json ${{ inputs.version_number }}
- name: Bump bws Version
if: ${{ inputs.project == 'bws' }}
run: cargo set-version -p bws ${{ inputs.version_number }}

### python
- name: Bump python-sdk Version
Expand Down
17 changes: 9 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 9 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ members = ["crates/*"]

# Global settings for all crates should be defined here
[workspace.package]
# Update using `cargo set-version -p bitwarden <new-version>`
version = "0.4.0"
authors = ["Bitwarden Inc"]
edition = "2021"
# Note: Changing rust-version should be considered a breaking change
Expand All @@ -15,12 +17,13 @@ keywords = ["bitwarden"]

# Define dependencies that are expected to be consistent across all crates
[workspace.dependencies]
bitwarden = { path = "crates/bitwarden", version = "0.4.0" }
bitwarden-api-api = { path = "crates/bitwarden-api-api", version = "0.2.3" }
bitwarden-api-identity = { path = "crates/bitwarden-api-identity", version = "=0.2.3" }
bitwarden-crypto = { path = "crates/bitwarden-crypto", version = "=0.1.0" }
bitwarden-exporters = { path = "crates/bitwarden-exporters", version = "=0.1.0" }
bitwarden-generators = { path = "crates/bitwarden-generators", version = "=0.1.0" }
bitwarden = { path = "crates/bitwarden", version = "=0.4.0" }
bitwarden-api-api = { path = "crates/bitwarden-api-api", version = "=0.4.0" }
bitwarden-api-identity = { path = "crates/bitwarden-api-identity", version = "=0.4.0" }
bitwarden-cli = { path = "crates/bitwarden-cli", version = "=0.4.0" }
bitwarden-crypto = { path = "crates/bitwarden-crypto", version = "=0.4.0" }
bitwarden-exporters = { path = "crates/bitwarden-exporters", version = "=0.4.0" }
bitwarden-generators = { path = "crates/bitwarden-generators", version = "=0.4.0" }

[workspace.lints.clippy]
unwrap_used = "deny"
Expand Down
2 changes: 1 addition & 1 deletion crates/bitwarden-api-api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[package]
name = "bitwarden-api-api"
version = "0.2.3"
description = """
Api bindings for the Bitwarden API.
"""
categories = ["api-bindings"]

version.workspace = true
authors.workspace = true
edition.workspace = true
rust-version.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/bitwarden-api-identity/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[package]
name = "bitwarden-api-identity"
version = "0.2.3"
description = """
Api bindings for the Bitwarden Identity API.
"""
categories = ["api-bindings"]

version.workspace = true
authors.workspace = true
edition.workspace = true
rust-version.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/bitwarden-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "bitwarden-cli"
version = "0.1.0"

version.workspace = true
authors.workspace = true
edition.workspace = true
rust-version.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/bitwarden-crypto/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[package]
name = "bitwarden-crypto"
version = "0.1.0"
description = """
Internal crate for the bitwarden crate. Do not use.
"""

version.workspace = true
authors.workspace = true
edition.workspace = true
rust-version.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/bitwarden-exporters/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[package]
name = "bitwarden-exporters"
version = "0.1.0"
description = """
Internal crate for the bitwarden crate. Do not use.
"""
exclude = ["/resources"]

version.workspace = true
authors.workspace = true
edition.workspace = true
rust-version.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/bitwarden-generators/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[package]
name = "bitwarden-generators"
version = "0.1.0"
description = """
Internal crate for the bitwarden crate. Do not use.
"""

version.workspace = true
authors.workspace = true
edition.workspace = true
rust-version.workspace = true
Expand Down
3 changes: 1 addition & 2 deletions crates/bitwarden-json/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@ secrets = ["bitwarden/secrets"] # Secrets manager API

[dependencies]
async-lock = ">=3.3.0, <4.0"
bitwarden = { workspace = true }
log = ">=0.4.18, <0.5"
schemars = ">=0.8.12, <0.9"
serde = { version = ">=1.0, <2.0", features = ["derive"] }
serde_json = ">=1.0.96, <2.0"

bitwarden = { workspace = true }

[lints]
workspace = true
7 changes: 3 additions & 4 deletions crates/bitwarden-napi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@ license-file.workspace = true
crate-type = ["cdylib", "rlib"]

[dependencies]
bitwarden-json = { path = "../bitwarden-json", version = "0.3.0", features = [
"secrets",
] }
env_logger = "0.11.1"
log = "0.4.20"
napi = { version = "2", features = ["async"] }
napi-derive = "2"

bitwarden-json = { path = "../bitwarden-json", version = "0.3.0", features = [
"secrets",
] }

[build-dependencies]
napi-build = "2.1.0"

Expand Down
3 changes: 1 addition & 2 deletions crates/bitwarden-py/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@ name = "bitwarden_py"
crate-type = ["cdylib"]

[dependencies]
bitwarden-json = { path = "../bitwarden-json", features = ["secrets"] }
pyo3 = { version = "0.20.2", features = ["extension-module"] }
pyo3-log = "0.9.0"

bitwarden-json = { path = "../bitwarden-json", features = ["secrets"] }

[build-dependencies]
pyo3-build-config = { version = "0.20.2" }

Expand Down
8 changes: 4 additions & 4 deletions crates/bitwarden-uniffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ bench = false

[dependencies]
async-lock = "3.3.0"
bitwarden = { workspace = true, features = ["mobile", "internal"] }
bitwarden-crypto = { workspace = true, features = ["mobile"] }
bitwarden-generators = { workspace = true, features = ["mobile"] }
chrono = { version = ">=0.4.26, <0.5", features = [
"serde",
"std",
], default-features = false }
env_logger = "0.11.1"
schemars = { version = ">=0.8, <0.9", optional = true }
uniffi = "=0.26.1"

bitwarden = { workspace = true, features = ["mobile", "internal"] }
bitwarden-crypto = { workspace = true, features = ["mobile"] }
bitwarden-generators = { workspace = true, features = ["mobile"] }
uuid = ">=1.3.3, <2"

[build-dependencies]
uniffi = { version = "=0.26.1", features = ["build"] }
Expand Down
2 changes: 2 additions & 0 deletions crates/bitwarden-uniffi/src/uniffi_support.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use bitwarden_crypto::{AsymmetricEncString, EncString, SensitiveString};
use uuid::Uuid;

// Forward the type definitions to the main bitwarden crate
type DateTime = chrono::DateTime<chrono::Utc>;
uniffi::ffi_converter_forward!(DateTime, bitwarden::UniFfiTag, crate::UniFfiTag);
uniffi::ffi_converter_forward!(EncString, bitwarden::UniFfiTag, crate::UniFfiTag);
uniffi::ffi_converter_forward!(AsymmetricEncString, bitwarden::UniFfiTag, crate::UniFfiTag);
uniffi::ffi_converter_forward!(SensitiveString, bitwarden::UniFfiTag, crate::UniFfiTag);
uniffi::ffi_converter_forward!(Uuid, bitwarden::UniFfiTag, crate::UniFfiTag);
18 changes: 18 additions & 0 deletions crates/bitwarden-uniffi/src/vault/ciphers.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::sync::Arc;

use bitwarden::vault::{Cipher, CipherListView, CipherView};
use uuid::Uuid;

use crate::{Client, Result};

Expand Down Expand Up @@ -47,4 +48,21 @@ impl ClientCiphers {
.decrypt_list(ciphers)
.await?)
}

/// Move a cipher to an organization, reencrypting the cipher key if necessary
pub async fn move_to_organization(
&self,
cipher: CipherView,
organization_id: Uuid,
) -> Result<CipherView> {
Ok(self
.0
.0
.read()
.await
.vault()
.ciphers()
.move_to_organization(cipher, organization_id)
.await?)
}
}
2 changes: 1 addition & 1 deletion crates/bitwarden/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[package]
name = "bitwarden"
version = "0.4.0"
description = """
Bitwarden Secrets Manager SDK
"""
keywords = ["bitwarden", "secrets-manager"]

version.workspace = true
authors.workspace = true
edition.workspace = true
rust-version.workspace = true
Expand Down
11 changes: 11 additions & 0 deletions crates/bitwarden/src/mobile/vault/client_ciphers.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use bitwarden_crypto::{Decryptable, Encryptable, LocateKey};
use uuid::Uuid;

use super::client_vault::ClientVault;
use crate::{
Expand Down Expand Up @@ -44,6 +45,16 @@ impl<'a> ClientCiphers<'a> {

Ok(cipher_views)
}

pub async fn move_to_organization(
&self,
mut cipher_view: CipherView,
organization_id: Uuid,
) -> Result<CipherView> {
let enc = self.client.get_encryption_settings()?;
cipher_view.move_to_organization(enc, organization_id)?;
Ok(cipher_view)
}
}

impl<'a> ClientVault<'a> {
Expand Down
Loading

0 comments on commit 92eeea5

Please sign in to comment.