Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework the WASM code #44

Merged
merged 50 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
b95d125
Rework the WASM code
Hinton Apr 10, 2023
3ab7955
Merge branch 'master' of github.com:bitwarden/sdk into feature/wasm
Hinton Apr 27, 2023
4b2468e
Fix documentation, remove any
Hinton Apr 27, 2023
cfd00a4
Merge branch 'master' of github.com:bitwarden/sdk into feature/wasm
Hinton Apr 27, 2023
b0eb600
Bump rimraf to 5
Hinton Apr 27, 2023
ed74aec
Refresh lock file
Hinton Apr 27, 2023
ff8b0b9
B64 encode fingerprint
Hinton Apr 27, 2023
df7970c
Add fingerprint response model (should we have this, or a generic jso…
Hinton Apr 27, 2023
eb45b2c
Merge branch 'master' of github.com:bitwarden/sdk into feature/wasm
Hinton May 2, 2023
9f8dc27
fmt
Hinton May 2, 2023
bc069fc
Add support for node.js wasm
Hinton May 4, 2023
0ec12ed
Change debug to release
Hinton May 4, 2023
5b2bea8
Add optimize command
Hinton May 4, 2023
2427e62
Merge branch 'master' of github.com:bitwarden/sdk into feature/wasm
Hinton Jun 5, 2023
68d32ac
Undo uneccesary change
Hinton Jun 5, 2023
ea553f9
Fix tests
Hinton Jun 5, 2023
fa66677
Change back default kdf iterations
Hinton Jun 6, 2023
6ad22c1
Remove package-lock
Hinton Jun 6, 2023
4faa056
Refresh the schemas
Hinton Jun 6, 2023
4277ae6
update readme
Hinton Jun 6, 2023
93bd786
Merge branch 'master' of github.com:bitwarden/sdk into feature/wasm
Hinton Jun 17, 2023
3068216
Update schemas
Hinton Jun 17, 2023
696000c
Merge branch 'master' of github.com:bitwarden/sdk into feature/wasm
Hinton Jul 21, 2023
0bc62b5
Refresh lockfile
Hinton Jul 21, 2023
1bdeab8
Revert accidental default feature
Hinton Jul 21, 2023
ed3093f
Merge branch 'master' of github.com:bitwarden/sdk into feature/wasm
Hinton Jul 31, 2023
f0476a6
Switch to unimplemented
Hinton Jul 31, 2023
30d79cd
Push forgotten lockfile
Hinton Jul 31, 2023
a2323de
Remove unused internal
Hinton Jul 31, 2023
d18be58
Remove last internal
Hinton Jul 31, 2023
2791410
Remove unused struct
Hinton Jul 31, 2023
e7fd7f1
Remove another unused struct
Hinton Jul 31, 2023
3cea843
Remove unused lockfile
Hinton Jul 31, 2023
5e4ea6b
Rollback fingerprint stuff
Hinton Jul 31, 2023
0d86f16
Fix workflow path
Hinton Jul 31, 2023
aa3fb80
Merge branch 'master' of github.com:bitwarden/sdk into feature/wasm
Hinton Nov 23, 2023
95a546d
Remove stdweb
Hinton Nov 23, 2023
7326b41
Cleanup gitignore
Hinton Nov 23, 2023
ee4b5bc
Merge branch 'master' of github.com:bitwarden/sdk into feature/wasm
Hinton Nov 23, 2023
5efa69e
Re-add missing std
Hinton Nov 23, 2023
ba02aa4
Remove `release-wasm`
Hinton Nov 24, 2023
dc715fb
Handle conditional loading of js wasm
Hinton Nov 24, 2023
06c646a
Cleanup
Hinton Nov 24, 2023
8d716b9
Update readme
Hinton Nov 24, 2023
2ef38f9
Merge branch 'master' of github.com:bitwarden/sdk into feature/wasm
Hinton Nov 27, 2023
4e85734
Merge branch 'master' of github.com:bitwarden/sdk into feature/wasm
Hinton Dec 7, 2023
3bb32ce
Remove instant
Hinton Dec 7, 2023
98acbb0
Move readme to bitwarden-wasm crate
Hinton Dec 8, 2023
7b3596c
Move readme and extract code to script
Hinton Dec 8, 2023
fe60a48
Add index.js to package.json
Hinton Dec 8, 2023
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
2 changes: 1 addition & 1 deletion .github/workflows/generate_schemas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
with:
name: schemas.ts
path: ${{ github.workspace }}/languages/js_webassembly/bitwarden_client/schemas.ts
path: ${{ github.workspace }}/languages/js/sdk-client/src/schemas.ts
if-no-files-found: error

- name: Upload c# schemas artifact
Expand Down
10 changes: 6 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ build/
bld/
[Bb]in/
[Oo]bj/
*.wasm

# Binary files
*.dylib
Expand Down Expand Up @@ -42,6 +43,7 @@ crates/bitwarden-napi/sdk-napi.*.node

# Complied TypeScript client
crates/bitwarden-napi/dist
languages/js/sdk-client/dist/

# Uniffi
languages/swift/BitwardenFFI.xcframework
Expand All @@ -52,11 +54,11 @@ languages/kotlin/sdk/src/main/java/com/bitwarden/sdk/bitwarden_uniffi.kt
languages/kotlin/sdk/src/main/java/com/bitwarden/core/bitwarden.kt

# Schemas
support/schemas
crates/bitwarden-napi/src-ts/bitwarden_client/schemas.ts
languages/csharp/Bitwarden.Sdk/schemas.cs
languages/js_webassembly/bitwarden_client/schemas.ts
languages/python/bitwarden_sdk/schemas.py
languages/cpp/include/schemas.hpp
languages/csharp/Bitwarden.Sdk/schemas.cs
languages/go/schema.go
languages/java/src/main/java/com/bitwarden/sdk/schema
languages/js/sdk-client/src/schemas.ts
languages/python/bitwarden_sdk/schemas.py
support/schemas
2 changes: 2 additions & 0 deletions Cargo.lock

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

7 changes: 5 additions & 2 deletions crates/bitwarden-wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ edition = "2021"
rust-version = "1.57"

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

[dependencies]
console_error_panic_hook = "0.1.7"
Expand All @@ -16,7 +16,10 @@ serde = { version = "1.0.193", features = ["derive"] }
wasm-bindgen = { version = "0.2.89", features = ["serde-serialize"] }
wasm-bindgen-futures = "0.4.39"

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

[dev-dependencies]
wasm-bindgen-test = "0.3.39"
23 changes: 23 additions & 0 deletions crates/bitwarden-wasm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Bitwarden-wasm

Requirements:

- `wasm32-unknown-unknown` rust target.
- `wasm-bindgen-cli` installed.
- `binaryen` installed for `wasm-opt` and `wasm2js`.

```bash
rustup target add wasm32-unknown-unknown
cargo install -f wasm-bindgen-cli
brew install binaryen
```

#### Build

```bash
# dev
./build.sh

# release
./build.sh -r
```
23 changes: 23 additions & 0 deletions crates/bitwarden-wasm/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Move to the root of the repository
cd "$(dirname "$0")"
cd ../../

if [ "$1" != "-r" ]; then
# Dev
cargo build -p bitwarden -p bitwarden-wasm --target wasm32-unknown-unknown --features wasm-bindgen
wasm-bindgen --target bundler --out-dir languages/js/wasm ./target/wasm32-unknown-unknown/debug/bitwarden_wasm.wasm
wasm-bindgen --target nodejs --out-dir languages/js/wasm/node ./target/wasm32-unknown-unknown/debug/bitwarden_wasm.wasm
else
# Release
cargo build -p bitwarden -p bitwarden-wasm --target wasm32-unknown-unknown --features wasm-bindgen --release
wasm-bindgen --target bundler --out-dir languages/js/wasm ./target/wasm32-unknown-unknown/release/bitwarden_wasm.wasm
wasm-bindgen --target nodejs --out-dir languages/js/wasm/node ./target/wasm32-unknown-unknown/release/bitwarden_wasm.wasm
fi

# Optimize size
wasm-opt -Os ./languages/js/wasm/bitwarden_wasm_bg.wasm -o ./languages/js/wasm/bitwarden_wasm_bg.wasm
wasm-opt -Os ./languages/js/wasm/node/bitwarden_wasm_bg.wasm -o ./languages/js/wasm/node/bitwarden_wasm_bg.wasm

# Transpile to JS
wasm2js ./languages/js/wasm/bitwarden_wasm_bg.wasm -o ./languages/js/wasm/bitwarden_wasm_bg.wasm.js
npx terser ./languages/js/wasm/bitwarden_wasm_bg.wasm.js -o ./languages/js/wasm/bitwarden_wasm_bg.wasm.js
4 changes: 3 additions & 1 deletion crates/bitwarden/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ secrets = [] # Secrets manager API
internal = [] # Internal testing methods
mobile = ["uniffi", "internal"] # Mobile-specific features

wasm-bindgen = ["chrono/wasmbind"]

[dependencies]
aes = ">=0.8.2, <0.9"
argon2 = { version = ">=0.5.0, <0.6", features = [
Expand Down Expand Up @@ -47,7 +49,7 @@ pbkdf2 = { version = ">=0.12.1, <0.13", default-features = false }
rand = ">=0.8.5, <0.9"
reqwest = { version = ">=0.11, <0.12", features = ["json"] }
rsa = ">=0.9.2, <0.10"
schemars = { version = ">=0.8, <0.9", features = ["uuid1", "chrono"] }
schemars = { version = ">=0.8.9, <0.9", features = ["uuid1", "chrono"] }
serde = { version = ">=1.0, <2.0", features = ["derive"] }
serde_json = ">=1.0.96, <2.0"
serde_qs = ">=0.12.0, <0.13"
Expand Down
File renamed without changes.
Loading