Skip to content

Commit e2dca98

Browse files
authored
[PM-25568] Build bitwarden commercial sdk internal in sdk (#479)
## 🎟️ Tracking <!-- Paste the link to the Jira or GitHub issue or otherwise describe / point to where this change is coming from. --> ## 📔 Objective <!-- Describe what the purpose of this PR is, for example what bug you're fixing or new feature you're adding. --> ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## 🦮 Reviewer guidelines <!-- Suggested interactions but feel free to use (or not) as you desire! --> - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹ️ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠️ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or ♻️ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes
1 parent b5d27e4 commit e2dca98

File tree

22 files changed

+614
-22
lines changed

22 files changed

+614
-22
lines changed

.github/workflows/build-wasm-internal.yml

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,21 @@ defaults:
1616

1717
jobs:
1818
build:
19-
name: Building @bitwarden/sdk-wasm-internal
19+
name: Building @bitwarden/sdk-wasm-internal - ${{matrix.license_type.readable}}
2020
runs-on: ubuntu-24.04
2121
permissions:
2222
contents: read
23+
strategy:
24+
matrix:
25+
license_type:
26+
- artifact_name: "wasm-internal"
27+
build_flags: ""
28+
npm_folder: "npm"
29+
readable: "open source license"
30+
- artifact_name: "commercial-wasm-internal"
31+
build_flags: "-b"
32+
npm_folder: "bitwarden_license/npm"
33+
readable: "commercial license"
2334

2435
steps:
2536
- name: Checkout repo
@@ -64,7 +75,7 @@ jobs:
6475
6576
- name: NPM setup
6677
run: npm ci
67-
working-directory: crates/bitwarden-wasm-internal/npm
78+
working-directory: crates/bitwarden-wasm-internal/${{ matrix.license_type.npm_folder }}
6879

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

8495
- name: Build
85-
run: ./build.sh -r
96+
run: ./build.sh -r ${{ matrix.license_type.build_flags }}
8697

8798
- name: Upload artifact
8899
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
89100
with:
90-
name: sdk-internal
91-
path: ${{ github.workspace }}/crates/bitwarden-wasm-internal/npm/*
101+
name: ${{ matrix.license_type.artifact_name }}
102+
path: ${{ github.workspace }}/crates/bitwarden-wasm-internal/${{ matrix.license_type.npm_folder }}/*
92103
if-no-files-found: error
93104

94105
trigger-wasm-publish:

Cargo.lock

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ bitwarden-api-identity = { path = "crates/bitwarden-api-identity", version = "=1
2525
bitwarden-auth = { path = "crates/bitwarden-auth", version = "=1.0.0" }
2626
bitwarden-cli = { path = "crates/bitwarden-cli", version = "=1.0.0" }
2727
bitwarden-collections = { path = "crates/bitwarden-collections", version = "=1.0.0" }
28+
bitwarden-commercial-vault = { path = "bitwarden_license/bitwarden-commercial-vault", version = "=1.0.0" }
2829
bitwarden-core = { path = "crates/bitwarden-core", version = "=1.0.0" }
2930
bitwarden-crypto = { path = "crates/bitwarden-crypto", version = "=1.0.0" }
3031
bitwarden-encoding = { path = "crates/bitwarden-encoding", version = "=1.0.0" }
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
[package]
2+
name = "bitwarden-commercial-vault"
3+
description = """
4+
Internal commercial crate for the bitwarden crate. Do not use.
5+
"""
6+
7+
version.workspace = true
8+
authors.workspace = true
9+
edition.workspace = true
10+
rust-version.workspace = true
11+
readme.workspace = true
12+
homepage.workspace = true
13+
repository.workspace = true
14+
license-file = "../../LICENSE_BITWARDEN.txt"
15+
keywords.workspace = true
16+
17+
[features]
18+
uniffi = ["dep:uniffi"] # Uniffi bindings
19+
wasm = [
20+
"dep:tsify",
21+
"dep:wasm-bindgen",
22+
"dep:wasm-bindgen-futures"
23+
] # WASM support
24+
25+
[dependencies]
26+
bitwarden-core = { workspace = true, features = ["internal"] }
27+
serde = { workspace = true }
28+
serde_json = { workspace = true }
29+
serde_repr = { workspace = true }
30+
tsify = { workspace = true, optional = true }
31+
uniffi = { workspace = true, optional = true }
32+
uuid = { workspace = true }
33+
wasm-bindgen = { workspace = true, optional = true }
34+
wasm-bindgen-futures = { workspace = true, optional = true }
35+
36+
[lints]
37+
workspace = true
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Bitwarden Commercial Vault
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#![doc = include_str!("../README.md")]
2+
3+
#[cfg(feature = "uniffi")]
4+
uniffi::setup_scaffolding!();
5+
#[cfg(feature = "uniffi")]
6+
mod uniffi_support;
7+
8+
mod vault_client;
9+
pub use vault_client::{CommercialVaultClient, CommercialVaultClientExt};
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
use uuid::Uuid;
2+
3+
uniffi::use_remote_type!(bitwarden_core::Uuid);
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
use bitwarden_core::Client;
2+
#[cfg(feature = "wasm")]
3+
use wasm_bindgen::prelude::*;
4+
5+
#[allow(missing_docs)]
6+
#[derive(Clone)]
7+
#[cfg_attr(feature = "wasm", wasm_bindgen)]
8+
pub struct CommercialVaultClient {
9+
#[allow(unused)]
10+
pub(crate) client: Client,
11+
}
12+
13+
impl CommercialVaultClient {
14+
fn new(client: Client) -> Self {
15+
Self { client }
16+
}
17+
}
18+
19+
#[cfg_attr(feature = "wasm", wasm_bindgen)]
20+
impl CommercialVaultClient {}
21+
22+
#[allow(missing_docs)]
23+
pub trait CommercialVaultClientExt {
24+
fn vault(&self) -> CommercialVaultClient;
25+
}
26+
27+
impl CommercialVaultClientExt for Client {
28+
fn vault(&self) -> CommercialVaultClient {
29+
CommercialVaultClient::new(self.clone())
30+
}
31+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[bindings.kotlin]
2+
package_name = "com.bitwarden.commercial.vault"
3+
generate_immutable_records = true
4+
android = true
5+
6+
[bindings.swift]
7+
ffi_module_name = "BitwardenCommercialVaultFFI"
8+
module_name = "BitwardenCommercialVault"
9+
generate_immutable_records = true

crates/bitwarden-pm/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ uniffi = [
2929
] # Uniffi bindings
3030
wasm = [
3131
"bitwarden-auth/wasm",
32+
"bitwarden-commercial-vault/wasm",
3233
"bitwarden-core/wasm",
3334
"bitwarden-exporters/wasm",
3435
"bitwarden-generators/wasm",
@@ -37,9 +38,11 @@ wasm = [
3738
"dep:wasm-bindgen-futures",
3839
"dep:tsify"
3940
] # WASM support
41+
bitwarden-license = ["dep:bitwarden-commercial-vault"]
4042

4143
[dependencies]
4244
bitwarden-auth = { workspace = true }
45+
bitwarden-commercial-vault = { workspace = true, optional = true }
4346
bitwarden-core = { workspace = true, features = ["internal"] }
4447
bitwarden-exporters = { workspace = true }
4548
bitwarden-fido = { workspace = true }

0 commit comments

Comments
 (0)