Skip to content
Open
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
21 changes: 16 additions & 5 deletions .github/workflows/build-wasm-internal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,21 @@ defaults:

jobs:
build:
name: Building @bitwarden/sdk-wasm-internal
name: Building @bitwarden/sdk-wasm-internal - ${{matrix.license_type.readable}}
runs-on: ubuntu-24.04
permissions:
contents: read
strategy:
matrix:
license_type:
- artifact_name: "wasm-internal"
build_flags: ""
npm_folder: "npm"
readable: "open source license"
- artifact_name: "commercial-wasm-internal"
build_flags: "-b"
npm_folder: "bitwarden_license/npm"
readable: "commercial license"

steps:
- name: Checkout repo
Expand Down Expand Up @@ -64,7 +75,7 @@ jobs:

- name: NPM setup
run: npm ci
working-directory: crates/bitwarden-wasm-internal/npm
working-directory: crates/bitwarden-wasm-internal/${{ matrix.license_type.npm_folder }}

- name: Install rust
uses: dtolnay/rust-toolchain@b3b07ba8b418998c39fb20f53e8b695cdcc8de1b # stable
Expand All @@ -82,13 +93,13 @@ jobs:
run: cargo install wasm-bindgen-cli --version 0.2.100

- name: Build
run: ./build.sh -r
run: ./build.sh -r ${{ matrix.license_type.build_flags }}

- name: Upload artifact
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
with:
name: sdk-internal
path: ${{ github.workspace }}/crates/bitwarden-wasm-internal/npm/*
name: ${{ matrix.license_type.artifact_name }}
path: ${{ github.workspace }}/crates/bitwarden-wasm-internal/${{ matrix.license_type.npm_folder }}/*
if-no-files-found: error

trigger-wasm-publish:
Expand Down
17 changes: 17 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ bitwarden-api-identity = { path = "crates/bitwarden-api-identity", version = "=1
bitwarden-auth = { path = "crates/bitwarden-auth", version = "=1.0.0" }
bitwarden-cli = { path = "crates/bitwarden-cli", version = "=1.0.0" }
bitwarden-collections = { path = "crates/bitwarden-collections", version = "=1.0.0" }
bitwarden-commercial-vault = { path = "bitwarden_license/bitwarden-commercial-vault", version = "=1.0.0" }
bitwarden-core = { path = "crates/bitwarden-core", version = "=1.0.0" }
bitwarden-crypto = { path = "crates/bitwarden-crypto", version = "=1.0.0" }
bitwarden-encoding = { path = "crates/bitwarden-encoding", version = "=1.0.0" }
Expand Down
37 changes: 37 additions & 0 deletions bitwarden_license/bitwarden-commercial-vault/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[package]
name = "bitwarden-commercial-vault"
description = """
Internal commercial crate for the bitwarden crate. Do not use.
"""

version.workspace = true
authors.workspace = true
edition.workspace = true
rust-version.workspace = true
readme.workspace = true
homepage.workspace = true
repository.workspace = true
license-file = "../../LICENSE_BITWARDEN.txt"
keywords.workspace = true

[features]
uniffi = ["dep:uniffi"] # Uniffi bindings
wasm = [
"dep:tsify",
"dep:wasm-bindgen",
"dep:wasm-bindgen-futures"
] # WASM support

[dependencies]
bitwarden-core = { workspace = true, features = ["internal"] }
serde = { workspace = true }
serde_json = { workspace = true }
serde_repr = { workspace = true }
tsify = { workspace = true, optional = true }
uniffi = { workspace = true, optional = true }
uuid = { workspace = true }
wasm-bindgen = { workspace = true, optional = true }
wasm-bindgen-futures = { workspace = true, optional = true }

[lints]
workspace = true
1 change: 1 addition & 0 deletions bitwarden_license/bitwarden-commercial-vault/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Bitwarden Commercial Vault
9 changes: 9 additions & 0 deletions bitwarden_license/bitwarden-commercial-vault/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#![doc = include_str!("../README.md")]

#[cfg(feature = "uniffi")]
uniffi::setup_scaffolding!();
#[cfg(feature = "uniffi")]
mod uniffi_support;

mod vault_client;
pub use vault_client::{CommercialVaultClient, CommercialVaultClientExt};
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
use uuid::Uuid;

uniffi::use_remote_type!(bitwarden_core::Uuid);
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
use bitwarden_core::Client;
#[cfg(feature = "wasm")]
use wasm_bindgen::prelude::*;

#[allow(missing_docs)]
#[derive(Clone)]
#[cfg_attr(feature = "wasm", wasm_bindgen)]
pub struct CommercialVaultClient {
#[allow(unused)]
pub(crate) client: Client,
}

impl CommercialVaultClient {
fn new(client: Client) -> Self {
Self { client }
}
}

#[cfg_attr(feature = "wasm", wasm_bindgen)]
impl CommercialVaultClient {}

#[allow(missing_docs)]
pub trait CommercialVaultClientExt {
fn vault(&self) -> CommercialVaultClient;
}

impl CommercialVaultClientExt for Client {
fn vault(&self) -> CommercialVaultClient {
CommercialVaultClient::new(self.clone())
}
}
9 changes: 9 additions & 0 deletions bitwarden_license/bitwarden-commercial-vault/uniffi.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[bindings.kotlin]
package_name = "com.bitwarden.commercial.vault"
generate_immutable_records = true
android = true

[bindings.swift]
ffi_module_name = "BitwardenCommercialVaultFFI"
module_name = "BitwardenCommercialVault"
generate_immutable_records = true
3 changes: 3 additions & 0 deletions crates/bitwarden-pm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ uniffi = [
] # Uniffi bindings
wasm = [
"bitwarden-auth/wasm",
"bitwarden-commercial-vault/wasm",
"bitwarden-core/wasm",
"bitwarden-exporters/wasm",
"bitwarden-generators/wasm",
Expand All @@ -37,9 +38,11 @@ wasm = [
"dep:wasm-bindgen-futures",
"dep:tsify"
] # WASM support
bitwarden-license = ["dep:bitwarden-commercial-vault"]

[dependencies]
bitwarden-auth = { workspace = true }
bitwarden-commercial-vault = { workspace = true, optional = true }
bitwarden-core = { workspace = true, features = ["internal"] }
bitwarden-exporters = { workspace = true }
bitwarden-fido = { workspace = true }
Expand Down
21 changes: 21 additions & 0 deletions crates/bitwarden-pm/src/commercial.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
use bitwarden_commercial_vault::CommercialVaultClientExt as _;
#[cfg(feature = "wasm")]
use wasm_bindgen::prelude::*;

#[cfg_attr(feature = "wasm", wasm_bindgen)]
/// Client for bitwarden licensed operations
pub struct CommercialPasswordManagerClient(bitwarden_core::Client);

impl CommercialPasswordManagerClient {
pub(crate) fn new(client: bitwarden_core::Client) -> Self {
Self(client)
}
}

#[cfg_attr(feature = "wasm", wasm_bindgen)]
impl CommercialPasswordManagerClient {
/// Vault item operations
pub fn vault(&self) -> bitwarden_commercial_vault::CommercialVaultClient {
self.0.vault()
}
}
11 changes: 11 additions & 0 deletions crates/bitwarden-pm/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#![doc = include_str!("../README.md")]

#[cfg(feature = "bitwarden-license")]
mod commercial;

use std::sync::Arc;

use bitwarden_auth::AuthClientExt as _;
Expand All @@ -21,6 +24,8 @@ pub mod clients {
pub use bitwarden_send::SendClient;
pub use bitwarden_vault::VaultClient;
}
#[cfg(feature = "bitwarden-license")]
pub use commercial::CommercialPasswordManagerClient;

/// The main entry point for the Bitwarden Password Manager SDK
pub struct PasswordManagerClient(pub bitwarden_core::Client);
Expand All @@ -46,6 +51,12 @@ impl PasswordManagerClient {
self.0.auth_new()
}

/// Bitwarden licensed operations
#[cfg(feature = "bitwarden-license")]
pub fn commercial(&self) -> CommercialPasswordManagerClient {
CommercialPasswordManagerClient::new(self.0.clone())
}

/// Crypto operations
pub fn crypto(&self) -> bitwarden_core::key_management::CryptoClient {
self.0.crypto()
Expand Down
6 changes: 6 additions & 0 deletions crates/bitwarden-wasm-internal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,17 @@ repository.workspace = true
license-file.workspace = true
keywords.workspace = true

[features]
bitwarden-license = ["bitwarden-pm/bitwarden-license", "dep:bitwarden-commercial-vault"]

[lib]
crate-type = ["cdylib"]

[dependencies]
async-trait = { workspace = true }
bitwarden-commercial-vault = { workspace = true, optional = true, features = [
"wasm",
] }
bitwarden-core = { workspace = true, features = ["wasm", "internal"] }
bitwarden-crypto = { workspace = true, features = ["wasm"] }
bitwarden-error = { workspace = true }
Expand Down
6 changes: 6 additions & 0 deletions crates/bitwarden-wasm-internal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ brew install binaryen
# dev
./build.sh

# dev with commercial license
./build.sh -b

# release
./build.sh -r

# release with commercial license
./build.sh -r -b
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
**/snippets/**/*.js
bitwarden_wasm_internal_bg.js
bitwarden_wasm_internal_bg.wasm
bitwarden_wasm_internal_bg.wasm.d.ts
bitwarden_wasm_internal_bg.wasm.js
bitwarden_wasm_internal_bg.mvp.wasm
bitwarden_wasm_internal.d.ts
bitwarden_wasm_internal.js
VERSION
Loading
Loading