diff --git a/README.md b/README.md index c2eebbd..1cebd81 100644 --- a/README.md +++ b/README.md @@ -173,6 +173,9 @@ pytest cd bindings/ts npm run build:wasm npm run build +# Node services use the CommonJS package instead of the bundler target: +npm run build:wasm:node +node vector-test.cjs pkg-node ``` ```ts diff --git a/bindings/ts/package.json b/bindings/ts/package.json index 41d608c..7a7fa01 100644 --- a/bindings/ts/package.json +++ b/bindings/ts/package.json @@ -8,6 +8,7 @@ "types": "dist/index.d.ts", "scripts": { "build:wasm": "wasm-pack build ../../crates/encryptoglyph --target bundler --out-dir ../../bindings/ts/pkg -- --features wasm", + "build:wasm:node": "wasm-pack build ../../crates/encryptoglyph --target nodejs --out-dir ../../bindings/ts/pkg-node -- --features wasm", "build": "tsc -p ." } } diff --git a/crates/encryptoglyph/Cargo.lock b/crates/encryptoglyph/Cargo.lock index fbb07c4..3f3427a 100644 --- a/crates/encryptoglyph/Cargo.lock +++ b/crates/encryptoglyph/Cargo.lock @@ -292,6 +292,7 @@ dependencies = [ "ed25519-dalek", "fpe", "getrandom 0.2.17", + "getrandom 0.4.3", "hkdf", "hmac", "ml-kem", @@ -389,9 +390,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" dependencies = [ "cfg-if", + "js-sys", "libc", "r-efi", "rand_core 0.10.1", + "wasm-bindgen", ] [[package]] diff --git a/crates/encryptoglyph/Cargo.toml b/crates/encryptoglyph/Cargo.toml index d268b40..8129edb 100644 --- a/crates/encryptoglyph/Cargo.toml +++ b/crates/encryptoglyph/Cargo.toml @@ -31,3 +31,9 @@ getrandom = "0.2" wasm-bindgen = { version = "0.2", optional = true } fpe = "0.6.1" blahaj = "0.7" + +# rand_core 0.10 pulls getrandom 0.4, which has no `js` feature. Enabling +# `wasm_js` on that version lets the wasm32 build use the locked graph. +# The direct 0.2 dependency stays named `getrandom` for getrandom::getrandom. +[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dependencies] +getrandom04 = { package = "getrandom", version = "0.4", features = ["wasm_js"] }