Skip to content

Commit 53f5f9b

Browse files
committed
Merge branch 'main' into ps/state-traits
2 parents 9d7153f + c0f7f72 commit 53f5f9b

File tree

20 files changed

+545
-12
lines changed

20 files changed

+545
-12
lines changed

.cargo/config.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ rustflags = ["--cfg", "aes_armv8"]
66

77
[target.wasm32-unknown-unknown]
88
rustflags = ['--cfg', 'getrandom_backend="wasm_js"']
9+
runner = 'wasm-bindgen-test-runner'
910

1011
# Enable support for 16k pages on Android, JNA is using these same flags
1112
# https://android-developers.googleblog.com/2024/08/adding-16-kb-page-size-to-android.html

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ jobs:
2525

2626
- name: Set version (PR)
2727
if: ${{ github.event_name == 'pull_request' }}
28+
env:
29+
PR_HEAD_REF: "${{ github.event.pull_request.head.ref }}"
2830
run: |
29-
echo REF_NAME="${{ github.event.pull_request.head.ref }}" >> $GITHUB_ENV
31+
echo REF_NAME="$PR_HEAD_REF" >> $GITHUB_ENV
3032
echo SHA="${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV
3133
3234
- name: Set env variables (Branch/Tag)
@@ -58,6 +60,9 @@ jobs:
5860
RUST_TOOLCHAIN="$(grep -oP '^channel.*"(\K.*?)(?=")' ../../rust-toolchain.toml)"
5961
echo "RUST_TOOLCHAIN=${RUST_TOOLCHAIN}" | tee -a "${GITHUB_OUTPUT}"
6062
63+
- name: NPM setup
64+
run: npm ci
65+
6166
- name: Install rust
6267
uses: dtolnay/rust-toolchain@56f84321dbccf38fb67ce29ab63e4754056677e0 # stable
6368
with:

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,16 @@ jobs:
4242
4343
- name: Version output
4444
id: version-output
45+
env:
46+
BRANCH: "${{ github.head_ref || github.ref_name }}"
4547
run: |
4648
if [ -z ${{ inputs.version }} ]; then
47-
BRANCH=${{ github.head_ref || github.ref_name }}
4849
VERSION=0.2.0-${BRANCH/\//-}.${{ github.run_number }}
4950
echo "version=$VERSION" >> $GITHUB_OUTPUT
51+
echo "### NPM Version: $VERSION" >> $GITHUB_STEP_SUMMARY
5052
else
5153
echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT
54+
echo "### NPM Version: ${{ inputs.version }}" >> $GITHUB_STEP_SUMMARY
5255
fi
5356
5457
npm:

.github/workflows/rust-test.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,37 @@ jobs:
4545
- name: Test
4646
run: cargo test --workspace --all-features
4747

48+
test-wasm:
49+
name: WASM
50+
runs-on: ubuntu-24.04
51+
52+
steps:
53+
- name: Checkout
54+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
55+
56+
- name: Set Rust Toolchain
57+
id: toolchain
58+
shell: bash
59+
run: |
60+
RUST_TOOLCHAIN="$(grep -oP '^channel.*"(\K.*?)(?=")' rust-toolchain.toml)"
61+
echo "RUST_TOOLCHAIN=${RUST_TOOLCHAIN}" | tee -a "${GITHUB_OUTPUT}"
62+
63+
- name: Install rust
64+
uses: dtolnay/rust-toolchain@56f84321dbccf38fb67ce29ab63e4754056677e0 # stable
65+
with:
66+
toolchain: "${{ steps.toolchain.outputs.RUST_TOOLCHAIN }}"
67+
targets: wasm32-unknown-unknown
68+
components: rust-src
69+
70+
- name: Cache cargo registry
71+
uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
72+
73+
- name: Install wasm-bindgen-cli
74+
run: cargo install wasm-bindgen-cli --version 0.2.100
75+
76+
- name: Test WASM
77+
run: cargo test --target wasm32-unknown-unknown -p bitwarden-wasm-internal -p bitwarden-threading -p bitwarden-error --all-features
78+
4879
coverage:
4980
name: Coverage
5081
runs-on: ubuntu-24.04

Cargo.lock

Lines changed: 19 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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ bitwarden-fido = { path = "crates/bitwarden-fido", version = "=1.0.0" }
2929
bitwarden-generators = { path = "crates/bitwarden-generators", version = "=1.0.0" }
3030
bitwarden-ipc = { path = "crates/bitwarden-ipc", version = "=1.0.0" }
3131
bitwarden-send = { path = "crates/bitwarden-send", version = "=1.0.0" }
32+
bitwarden-threading = { path = "crates/bitwarden-threading", version = "=1.0.0" }
3233
bitwarden-sm = { path = "bitwarden_license/bitwarden-sm", version = "=1.0.0" }
3334
bitwarden-ssh = { path = "crates/bitwarden-ssh", version = "=1.0.0" }
3435
bitwarden-vault = { path = "crates/bitwarden-vault", version = "=1.0.0" }
@@ -63,6 +64,7 @@ validator = { version = ">=0.18.1, <0.20", features = ["derive"] }
6364
wasm-bindgen = { version = ">=0.2.91, <0.3", features = ["serde-serialize"] }
6465
js-sys = { version = ">=0.3.72, <0.4" }
6566
wasm-bindgen-futures = "0.4.41"
67+
wasm-bindgen-test = "0.3.45"
6668

6769
# There is an incompatibility when using pkcs5 and chacha20 on wasm builds. This can be removed once a new
6870
# rustcrypto-formats crate version is released since the fix has been upstreamed.

crates/bitwarden-error/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ workspace = true
3434
[dev-dependencies]
3535
serde.workspace = true
3636
trybuild = "1.0.101"
37-
wasm-bindgen-test = "0.3.45"
37+
wasm-bindgen-test = { workspace = true }
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[target.wasm32-unknown-unknown]
2+
runner = 'wasm-bindgen-test-runner'

crates/bitwarden-threading/Cargo.toml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
[package]
2+
name = "bitwarden-threading"
3+
version.workspace = true
4+
authors.workspace = true
5+
edition.workspace = true
6+
rust-version.workspace = true
7+
homepage.workspace = true
8+
repository.workspace = true
9+
license-file.workspace = true
10+
keywords.workspace = true
11+
12+
[dependencies]
13+
bitwarden-error = { workspace = true }
14+
log = { workspace = true }
15+
serde = { workspace = true }
16+
serde_json = { workspace = true }
17+
thiserror = { workspace = true }
18+
tokio = { features = ["sync", "time", "rt"], workspace = true }
19+
20+
[target.'cfg(target_arch="wasm32")'.dependencies]
21+
js-sys = { workspace = true }
22+
tsify-next = { workspace = true }
23+
wasm-bindgen = { workspace = true }
24+
wasm-bindgen-futures = { workspace = true }
25+
26+
[dev-dependencies]
27+
async-trait = "0.1.88"
28+
console_error_panic_hook = "0.1.7"
29+
js-sys = { workspace = true }
30+
tsify-next = { workspace = true }
31+
wasm-bindgen = { workspace = true }
32+
wasm-bindgen-futures = { workspace = true }
33+
wasm-bindgen-test = { workspace = true }
34+
35+
[lints]
36+
workspace = true

crates/bitwarden-threading/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# bitwarden-threading
2+
3+
Utility crate for Bitwarden SDK to handle threading and async quirks in FFI contexts.
4+
5+
## WASM Testing
6+
7+
To run the WASM tests, you can use the following command:
8+
9+
```bash
10+
cargo test --target wasm32-unknown-unknown --all-features -- --nocapture
11+
```

0 commit comments

Comments
 (0)