
Research
/Security News
Critical Vulnerability in NestJS Devtools: Localhost RCE via Sandbox Escape
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Universal WebAssembly tools for JavaScript.
This project aims to make a common and future-proof solution for WebAssembly modules support suitable for various JavaScript runtimes, frameworks, and build Tools following WebAssembly/ES Module Integration proposal from WebAssembly Community Group as much as possible while also trying to keep compatibility with current ecosystem libraries.
The development will be split into multiple stages.
[!IMPORTANT] This Project is under development! See the linked discussions to be involved!
.wasm
files (unjs/unwasm#3)When importing a .wasm
module using unwasm, it will take steps to transform the binary and finally resolve to an ESM module that allows you to interact with the WASM module. The returned result is a Proxy object. This proxy allows to use of an elegant API while also having both backward and forward compatibility with WASM modules as the ecosystem evolves.
WebAssembly modules that don't require any imports, can be imported simply like you import any other ESM module.
Using static import:
import { sum } from "unwasm/examples/sum.wasm";
Using dynamic import:
const { sum } = await import("unwasm/examples/sum.wasm").then(
(mod) => mod.default,
);
In case your WebAssembly module requires an import object (which is likely!), the usage syntax would be slightly different as we need to initate the module with an import object first.
Using static import with imports object:
import { rand, $init } from "unwasm/examples/rand.wasm";
await $init({
env: {
seed: () => () => Math.random() * Date.now(),
},
});
Using dynamic import with imports object:
const { rand } = await import("unwasm/examples/rand.wasm").then((mod) =>
mod.$init({
env: {
seed: () => () => Math.random() * Date.now(),
},
}),
);
[!NOTE] When using static import syntax, and before calling
$init
, the named exports will be wrapped into a function by proxy that waits for the module initialization and before that, if called, will immediately try to call$init()
and return a Promise that calls a function after init.
[!NOTE] Named exports with the
$
prefix are reserved for unwasm. In case your module uses them, you can access them from the$exports
property.
Unwasm needs to transform the .wasm
imports to the compatible bindings. Currently only method is using a rollup plugin. In the future, more usage methods will be introduced.
First, install the unwasm
npm package:
# npm
npm install --dev unwasm
# yarn
yarn add -D unwasm
# pnpm
pnpm i -D unwasm
# bun
bun i -D unwasm
// rollup.config.js
import unwasmPlugin from "unwasm/plugin";
export default {
plugins: [
unwasmPlugin.rollup({
/* options */
}),
],
};
esmImport
: Direct import the wasm file instead of bundling, required in Cloudflare Workers (default is false
)lazy
: Import .wasm
files using a lazily evaluated promise for compatibility with runtimes without top-level await support (default is false
)corepack enable
pnpm install
pnpm dev
Made with 💛
Published under MIT License.
v0.2.0
$init
import (9673e5c)FAQs
WebAssembly tools for JavaScript
The npm package unwasm receives a total of 575,579 weekly downloads. As such, unwasm popularity was classified as popular.
We found that unwasm demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.